Issue #2611758 by swentel, webflo, zuuperman: Field UI table is broken for nested elements
parent
4f91db15c1
commit
5ad579744e
|
@ -85,11 +85,12 @@ class FieldUiTable extends Table {
|
|||
if ($depth = count($parents[$name])) {
|
||||
$children = Element::children($row);
|
||||
$cell = current($children);
|
||||
$row[$cell]['#prefix'] = [
|
||||
$indentation = [
|
||||
'#theme' => 'indentation',
|
||||
'#size' => $depth,
|
||||
'#suffix' => isset($row[$cell]['#prefix']) ? $row[$cell]['#prefix'] : '',
|
||||
];
|
||||
$row[$cell]['#prefix'] = \Drupal::service('renderer')->render($indentation);
|
||||
}
|
||||
|
||||
// Add row id and associate JS settings.
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\field_ui\Tests\FieldUIIndentationTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\field_ui\Tests;
|
||||
|
||||
use Drupal\simpletest\WebTestBase;
|
||||
|
||||
/**
|
||||
* Tests indentation on Field UI.
|
||||
*
|
||||
* @group field_ui
|
||||
*/
|
||||
class FieldUIIndentationTest extends WebTestBase {
|
||||
|
||||
/**
|
||||
* Modules to install.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('node', 'field_ui', 'field_ui_test');
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
// Create a test user.
|
||||
$admin_user = $this->drupalCreateUser(array('access content', 'administer content types', 'administer node display'));
|
||||
$this->drupalLogin($admin_user);
|
||||
|
||||
// Create Basic page node type.
|
||||
$this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page'));
|
||||
|
||||
}
|
||||
|
||||
function testIndentation() {
|
||||
$this->drupalGet('admin/structure/types/manage/page/display');
|
||||
$this->assertRaw('js-indentation indentation');
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
name: 'Field UI test'
|
||||
type: module
|
||||
description: 'Support module for Field UI tests.'
|
||||
core: 8.x
|
||||
package: Testing
|
||||
version: VERSION
|
|
@ -0,0 +1,59 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Field UI test module.
|
||||
*/
|
||||
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
use Drupal\Core\Render\Element;
|
||||
|
||||
/**
|
||||
* Implements hook_form_FORM_BASE_ID_alter().
|
||||
*/
|
||||
function field_ui_test_form_entity_view_display_edit_form_alter(&$form, FormStateInterface $form_state) {
|
||||
$table = &$form['fields'];
|
||||
|
||||
foreach (Element::children($table) as $name) {
|
||||
$table[$name]['parent_wrapper']['parent']['#options'] = array('indent' => 'Indent');
|
||||
$table[$name]['parent_wrapper']['parent']['#default_value'] = 'indent';
|
||||
}
|
||||
|
||||
$table['indent'] = [
|
||||
'#attributes' => array('class' => array('draggable', 'field-group'), 'id' => 'indent-id'),
|
||||
'#row_type' => 'group',
|
||||
'#region_callback' => 'field_ui_test_region_callback',
|
||||
'#js_settings' => array('rowHandler' => 'group'),
|
||||
'human_name' => array(
|
||||
'#markup' => 'Indent',
|
||||
'#prefix' => '<span class="group-label">',
|
||||
'#suffix' => '</span>',
|
||||
),
|
||||
'weight' => array(
|
||||
'#type' => 'textfield',
|
||||
'#default_value' => 0,
|
||||
'#size' => 3,
|
||||
'#attributes' => array('class' => array('field-weight')),
|
||||
),
|
||||
'parent_wrapper' => array(
|
||||
'parent' => array(
|
||||
'#type' => 'select',
|
||||
'#options' => array('indent' => 'Indent'),
|
||||
'#empty_value' => '',
|
||||
'#default_value' => '',
|
||||
'#attributes' => array('class' => array('field-parent')),
|
||||
'#parents' => array('fields', 'indent', 'parent'),
|
||||
),
|
||||
'hidden_name' => array(
|
||||
'#type' => 'hidden',
|
||||
'#default_value' => 'indent',
|
||||
'#attributes' => array('class' => array('field-name')),
|
||||
),
|
||||
),
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
function field_ui_test_region_callback($row) {
|
||||
return 'content';
|
||||
}
|
Loading…
Reference in New Issue