diff --git a/core/modules/field_ui/src/Element/FieldUiTable.php b/core/modules/field_ui/src/Element/FieldUiTable.php index 8c80baa95ea2..1dd5e62840f7 100644 --- a/core/modules/field_ui/src/Element/FieldUiTable.php +++ b/core/modules/field_ui/src/Element/FieldUiTable.php @@ -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. diff --git a/core/modules/field_ui/src/Tests/FieldUIIndentationTest.php b/core/modules/field_ui/src/Tests/FieldUIIndentationTest.php new file mode 100644 index 000000000000..6b9ad7eb6350 --- /dev/null +++ b/core/modules/field_ui/src/Tests/FieldUIIndentationTest.php @@ -0,0 +1,45 @@ +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'); + } +} diff --git a/core/modules/field_ui/tests/modules/field_ui_test/field_ui_test.info.yml b/core/modules/field_ui/tests/modules/field_ui_test/field_ui_test.info.yml new file mode 100644 index 000000000000..aa8a97a43815 --- /dev/null +++ b/core/modules/field_ui/tests/modules/field_ui_test/field_ui_test.info.yml @@ -0,0 +1,6 @@ +name: 'Field UI test' +type: module +description: 'Support module for Field UI tests.' +core: 8.x +package: Testing +version: VERSION diff --git a/core/modules/field_ui/tests/modules/field_ui_test/field_ui_test.module b/core/modules/field_ui/tests/modules/field_ui_test/field_ui_test.module new file mode 100644 index 000000000000..562168fac550 --- /dev/null +++ b/core/modules/field_ui/tests/modules/field_ui_test/field_ui_test.module @@ -0,0 +1,59 @@ + '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' => '', + '#suffix' => '', + ), + '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'; +}