Verified Commit 7598b15a authored by Lauri Timmanee's avatar Lauri Timmanee
Browse files

Issue #3039185 by nord102, yogeshmpawar, swentel, tim.plunkett, manishsaharan,...

Issue #3039185 by nord102, yogeshmpawar, swentel, tim.plunkett, manishsaharan, nkoporec, catch, bkosborne: Allow field blocks to display the configuration label when set in Layout Builder
parent 710278cc
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -159,7 +159,11 @@ public function build() {
    $display_settings['third_party_settings']['layout_builder']['view_mode'] = $this->getContextValue('view_mode');
    $entity = $this->getEntity();
    try {
      $build = $entity->get($this->fieldName)->view($display_settings);
      $build = [];
      $view = $entity->get($this->fieldName)->view($display_settings);
      if ($view) {
        $build = [$view];
      }
    }
    // @todo Remove in https://www.drupal.org/project/drupal/issues/2367555.
    catch (EnforcedResponseException $e) {
+40 −0
Original line number Diff line number Diff line
@@ -1305,6 +1305,46 @@ public function testBlockPlaceholder() {
    $assert_session->pageTextContains($block_content);
  }

  /**
   * Tests the ability to use a specified block label for field blocks.
   */
  public function testFieldBlockLabel() {
    $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';
    $this->drupalGet("$field_ui_prefix/display/default");
    $this->submitForm(['layout[enabled]' => TRUE], 'Save');

    // Customize the default view mode.
    $this->drupalGet("$field_ui_prefix/display/default/layout");

    // Add a body block whose label will be overridden.
    $this->clickLink('Add block');
    $this->clickLink('Body');

    // Enable the Label Display and set the Label to a modified field
    // block label.
    $modified_field_block_label = 'Modified Field Block Label';
    $page->checkField('settings[label_display]');
    $page->fillField('settings[label]', $modified_field_block_label);

    // Save the block and layout.
    $page->pressButton('Add block');
    $page->pressButton('Save layout');

    // Revisit the default layout view mode page.
    $this->drupalGet("$field_ui_prefix/display/default/layout");

    // The modified field block label is displayed.
    $assert_session->pageTextContains($modified_field_block_label);
  }

  /**
   * Tests a custom alter of the overrides form.
   */
+1 −1
Original line number Diff line number Diff line
@@ -272,7 +272,7 @@ public function testBuild(PromiseInterface $promise, $expected_markup, $log_mess
      ],
    ];
    if ($expected_markup) {
      $expected['content']['#markup'] = $expected_markup;
      $expected[0]['content']['#markup'] = $expected_markup;
    }

    $actual = $block->build();