Issue #2870410 by tim.plunkett: Field UI should show fields with unknown regions in the "Disabled" section
parent
4971d77637
commit
992ed45b26
|
|
@ -0,0 +1,16 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file
|
||||||
|
* Contains hook implementations for field_layout_test.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implements hook_layout_alter().
|
||||||
|
*/
|
||||||
|
function field_layout_test_layout_alter(&$definitions) {
|
||||||
|
/** @var \Drupal\Core\Layout\LayoutDefinition[] $definitions */
|
||||||
|
if (\Drupal::state()->get('field_layout_test.alter_regions') && isset($definitions['layout_onecol'])) {
|
||||||
|
$definitions['layout_onecol']->setRegions(['foo' => ['label' => 'Foo']]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -14,7 +14,7 @@ class FieldLayoutTest extends BrowserTestBase {
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public static $modules = ['field_layout', 'field_ui', 'node'];
|
public static $modules = ['field_layout', 'field_ui', 'node', 'field_layout_test'];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
|
|
@ -57,6 +57,22 @@ class FieldLayoutTest extends BrowserTestBase {
|
||||||
$this->assertSession()->optionExists('fields[body][region]', 'content');
|
$this->assertSession()->optionExists('fields[body][region]', 'content');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests that changes to the regions still leave the fields visible.
|
||||||
|
*/
|
||||||
|
public function testRegionChanges() {
|
||||||
|
$this->drupalGet('admin/structure/types/manage/article/display');
|
||||||
|
$this->assertEquals(['Content', 'Disabled'], $this->getRegionTitles());
|
||||||
|
$this->assertSession()->optionExists('fields[body][region]', 'content');
|
||||||
|
|
||||||
|
\Drupal::state()->set('field_layout_test.alter_regions', TRUE);
|
||||||
|
\Drupal::service('plugin.cache_clearer')->clearCachedDefinitions();
|
||||||
|
|
||||||
|
$this->drupalGet('admin/structure/types/manage/article/display');
|
||||||
|
$this->assertEquals(['Foo', 'Disabled'], $this->getRegionTitles());
|
||||||
|
$this->assertSession()->optionExists('fields[body][region]', 'hidden');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the region titles on the page.
|
* Gets the region titles on the page.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,7 @@ class FieldUiTable extends Table {
|
||||||
unset($list[$name]);
|
unset($list[$name]);
|
||||||
|
|
||||||
// Determine the region for the row.
|
// Determine the region for the row.
|
||||||
$region_name = call_user_func($row['#region_callback'], $row);
|
$region_name = call_user_func_array($row['#region_callback'], [&$row]);
|
||||||
|
|
||||||
// Add the element in the tree.
|
// Add the element in the tree.
|
||||||
$target = &$trees[$region_name][''];
|
$target = &$trees[$region_name][''];
|
||||||
|
|
|
||||||
|
|
@ -817,12 +817,12 @@ abstract class EntityDisplayFormBase extends EntityForm {
|
||||||
* @return string|null
|
* @return string|null
|
||||||
* The region name this row belongs to.
|
* The region name this row belongs to.
|
||||||
*/
|
*/
|
||||||
public function getRowRegion($row) {
|
public function getRowRegion(&$row) {
|
||||||
switch ($row['#row_type']) {
|
$regions = $this->getRegions();
|
||||||
case 'field':
|
if (!isset($regions[$row['region']['#value']])) {
|
||||||
case 'extra_field':
|
$row['region']['#value'] = 'hidden';
|
||||||
return $row['region']['#value'] ?: 'hidden';
|
|
||||||
}
|
}
|
||||||
|
return $row['region']['#value'];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue