Issue #3069578 by danflanagan8, YurkinPark, ayushmishra206, andersen_ti, waspper, tim.plunkett, Anybody, Regnoy, larowlan: Layout builder doesn't show new "extra fields"

merge-requests/25/head
catch 2020-10-08 16:43:50 +01:00
parent 876073f12e
commit b94f170f8a
5 changed files with 39 additions and 1 deletions

View File

@ -381,6 +381,12 @@ block.settings.field_block:*:*:*:
formatter:
type: field_formatter
block.settings.extra_field_block:*:*:*:
type: block_settings
mapping:
formatter:
type: field_formatter
# Schema for entity actions.
action.configuration.entity:*:*:
type: action_configuration_default

View File

@ -535,7 +535,7 @@ class LayoutBuilderEntityViewDisplay extends BaseEntityViewDisplay implements La
foreach ($this->getSections() as $section) {
foreach ($section->getComponents() as $component) {
$plugin = $component->getPlugin();
if ($plugin instanceof DerivativeInspectionInterface && $plugin->getBaseId() === 'field_block') {
if ($plugin instanceof DerivativeInspectionInterface && in_array($plugin->getBaseId(), ['field_block', 'extra_field_block'], TRUE)) {
// FieldBlock derivative IDs are in the format
// [entity_type]:[bundle]:[field].
list(, , $field_block_field_name) = explode(PluginBase::DERIVATIVE_SEPARATOR, $plugin->getDerivativeId());

View File

@ -85,6 +85,10 @@ class ExtraFieldBlock extends BlockBase implements ContextAwarePluginInterface,
public function defaultConfiguration() {
return [
'label_display' => FALSE,
'formatter' => [
'settings' => [],
'third_party_settings' => [],
],
];
}

View File

@ -47,6 +47,12 @@ function layout_builder_test_entity_extra_field_info() {
'description' => t('Extra description'),
'weight' => 0,
];
$extra['node']['bundle_with_section_field']['display']['layout_builder_test_2'] = [
'label' => t('Extra Field 2'),
'description' => t('Extra Field 2 description'),
'weight' => 0,
'visible' => FALSE,
];
return $extra;
}
@ -59,6 +65,11 @@ function layout_builder_test_node_view(array &$build, EntityInterface $entity, E
'#markup' => 'Extra, Extra read all about it.',
];
}
if ($display->getComponent('layout_builder_test_2')) {
$build['layout_builder_test_2'] = [
'#markup' => 'Extra Field 2 is hidden by default.',
];
}
}
/**

View File

@ -904,6 +904,23 @@ class LayoutBuilderTest extends BrowserTestBase {
$this->drupalGet('node');
$assert_session->linkExists('Read more');
// Consider an extra field hidden by default. Make sure it's not displayed.
$this->drupalGet('node/1');
$assert_session->pageTextNotContains('Extra Field 2 is hidden by default.');
// View the layout and add the extra field that is not visible by default.
$this->drupalGet('admin/structure/types/manage/bundle_with_section_field/display/default/layout');
$assert_session->pageTextNotContains('Extra Field 2');
$page->clickLink('Add block');
$page->clickLink('Extra Field 2');
$page->pressButton('Add block');
$assert_session->pageTextContains('Extra Field 2');
$page->pressButton('Save layout');
// Confirm that the newly added extra field is visible.
$this->drupalGet('node/1');
$assert_session->pageTextContains('Extra Field 2 is hidden by default.');
}
/**