Unverified Commit a2284209 authored by alexpott's avatar alexpott

Issue #2998215 by tim.plunkett, Ronak.addweb, bkosborne: PHP notices/warnings...

Issue #2998215 by tim.plunkett, Ronak.addweb, bkosborne: PHP notices/warnings when managing display for non-default view mode when LB is enabled w/ overrides
parent 20c250eb
......@@ -47,6 +47,10 @@ public function buildForm(array $form, FormStateInterface $form_state, SectionSt
public function form(array $form, FormStateInterface $form_state) {
$form = parent::form($form, $form_state);
// Remove the Layout Builder field from the list.
$form['#fields'] = array_diff($form['#fields'], ['layout_builder__layout']);
unset($form['fields']['layout_builder__layout']);
$is_enabled = $this->entity->isLayoutBuilderEnabled();
if ($is_enabled) {
// Hide the table of fields.
......@@ -54,10 +58,6 @@ public function form(array $form, FormStateInterface $form_state) {
$form['#fields'] = [];
$form['#extra'] = [];
}
else {
// Remove the Layout Builder field from the list.
$form['#fields'] = array_diff($form['#fields'], ['layout_builder__layout']);
}
$form['manage_layout'] = [
'#type' => 'link',
......@@ -180,7 +180,7 @@ public function entityFormEntityBuild($entity_type_id, LayoutEntityDisplayInterf
* {@inheritdoc}
*/
protected function buildFieldRow(FieldDefinitionInterface $field_definition, array $form, FormStateInterface $form_state) {
if ($this->entity->isLayoutBuilderEnabled() || $field_definition->getType() === 'layout_section') {
if ($this->entity->isLayoutBuilderEnabled()) {
return [];
}
......
......@@ -225,6 +225,33 @@ public function testLayoutBuilderUi() {
$assert_session->elementNotExists('css', '.field--name-field-my-text');
}
/**
* Tests that a non-default view mode works as expected.
*/
public function testNonDefaultViewMode() {
$assert_session = $this->assertSession();
$page = $this->getSession()->getPage();
$this->drupalLogin($this->drupalCreateUser([
'configure any layout',
'administer node display',
]));
$field_ui_prefix = 'admin/structure/types/manage/bundle_with_section_field';
// Allow overrides for the layout.
$this->drupalGet("$field_ui_prefix/display/default");
$page->checkField('layout[enabled]');
$page->pressButton('Save');
$page->checkField('layout[allow_custom]');
$page->pressButton('Save');
$this->clickLink('Teaser');
// Enabling Layout Builder for the default mode does not affect the teaser.
$assert_session->addressEquals("$field_ui_prefix/display/teaser");
$assert_session->elementNotExists('css', '#layout-builder__layout');
$assert_session->checkboxNotChecked('layout[enabled]');
}
/**
* Tests that component's dependencies are respected during removal.
*/
......
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