Skip to content
Snippets Groups Projects
Verified Commit fbec11ff 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

(cherry picked from commit 7598b15a)
parent 7b0afe89
No related branches found
No related tags found
29 merge requests!11628Update file MediaLibraryWidget.php,!7564Revert "Issue #3364773 by roshnichordiya, Chris Matthews, thakurnishant_06,...,!5752Issue #3275828 by joachim, quietone, bradjones1, Berdir: document the reason...,!5688Issue #3087950 by Utkarsh_33, swatichouhan012, komalk, Sivaji_Ganesh_Jojodae,...,!5627Issue #3261805: Field not saved when change of 0 on string start,!5427Issue #3338518: send credentials in ajax if configured in CORS settings.,!5395Issue #3387916 by fjgarlin, Spokje: Each GitLab job exposes user email,!5217Issue #3386607 by alexpott: Improve spell checking in commit-code-check.sh,!5064Issue #3379522 by finnsky, Gauravvvv, kostyashupenko, smustgrave, Chi: Revert...,!5040SDC ComponentElement: Transform slots scalar values to #plain_text instead of throwing an exception,!4958Issue #3392147: Whitelist IP for a Ban module.,!4942Issue #3365945: Errors: The following table(s) do not have a primary key: forum_index,!4894Issue #3280279: Add API to allow sites to opt in to upload SVG images in CKEditor 5,!4857Issue #3336994: StringFormatter always displays links to entity even if the user in context does not have access,!4856Issue #3336994: StringFormatter always displays links to entity even if the user in context does not have access,!4788Issue #3272985: RSS Feed header reverts to text/html when cached,!4716Issue #3362929: Improve 400 responses for broken/invalid image style routes,!4553Draft: Issue #2980951: Permission to see own unpublished comments in comment thread,!4273Add UUID to sections,!4192Issue #3367204: [CKEditor5] Missing dependency on drupal.ajax,!3679Issue #115801: Allow password on registration without disabling e-mail verification,!3676Issue #3347497: Introduce a FetchModeTrait to allow emulating PDO fetch modes,!3106Issue #3017548: "Filtered HTML" text format does not support manual teaser break (<!--break-->),!3066Issue #3325175: Deprecate calling \Drupal\menu_link_content\Form\MenuLinkContentForm::_construct() with the $language_manager argument,!3004Issue #2463967: Use .user.ini file for PHP settings,!2851Issue #2264739: Allow multiple field widgets to not use tabledrag,!1484Exposed filters get values from URL when Ajax is on,!925Issue #2339235: Remove taxonomy hard dependency on node module,!872Draft: Issue #3221319: Race condition when creating menu links and editing content deletes menu links
...@@ -159,7 +159,11 @@ public function build() { ...@@ -159,7 +159,11 @@ public function build() {
$display_settings['third_party_settings']['layout_builder']['view_mode'] = $this->getContextValue('view_mode'); $display_settings['third_party_settings']['layout_builder']['view_mode'] = $this->getContextValue('view_mode');
$entity = $this->getEntity(); $entity = $this->getEntity();
try { 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. // @todo Remove in https://www.drupal.org/project/drupal/issues/2367555.
catch (EnforcedResponseException $e) { catch (EnforcedResponseException $e) {
......
...@@ -1305,6 +1305,46 @@ public function testBlockPlaceholder() { ...@@ -1305,6 +1305,46 @@ public function testBlockPlaceholder() {
$assert_session->pageTextContains($block_content); $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. * Tests a custom alter of the overrides form.
*/ */
......
...@@ -272,7 +272,7 @@ public function testBuild(PromiseInterface $promise, $expected_markup, $log_mess ...@@ -272,7 +272,7 @@ public function testBuild(PromiseInterface $promise, $expected_markup, $log_mess
], ],
]; ];
if ($expected_markup) { if ($expected_markup) {
$expected['content']['#markup'] = $expected_markup; $expected[0]['content']['#markup'] = $expected_markup;
} }
$actual = $block->build(); $actual = $block->build();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment