Commit 5ad57974 authored by catch's avatar catch

Issue #2611758 by swentel, webflo, zuuperman: Field UI table is broken for nested elements

parent 4f91db15
......@@ -85,11 +85,12 @@ public static function tablePreRender($elements) {
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.
......
<?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');
}
}
name: 'Field UI test'
type: module
description: 'Support module for Field UI tests.'
core: 8.x
package: Testing
version: VERSION
<?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';
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment