diff --git a/core/modules/layout_builder/src/Form/BlockPluginTranslationForm.php b/core/modules/layout_builder/src/Form/BlockPluginTranslationForm.php index 63f1456fbb..3ed489fdce 100644 --- a/core/modules/layout_builder/src/Form/BlockPluginTranslationForm.php +++ b/core/modules/layout_builder/src/Form/BlockPluginTranslationForm.php @@ -36,7 +36,6 @@ public function __construct($current_langcode) { $this->currentLangcode = $current_langcode; } - /** * {@inheritdoc} */ diff --git a/core/modules/layout_builder/src/Plugin/Block/InlineBlock.php b/core/modules/layout_builder/src/Plugin/Block/InlineBlock.php index 21114b0064..44157c427b 100644 --- a/core/modules/layout_builder/src/Plugin/Block/InlineBlock.php +++ b/core/modules/layout_builder/src/Plugin/Block/InlineBlock.php @@ -158,7 +158,7 @@ public static function processBlockForm(array $element, FormStateInterface $form $element['revision_log']['#access'] = FALSE; $element['info']['#access'] = FALSE; if (isset($element['langcode'])) { - $element['langcode'] = FALSE; + $element['langcode']['langcode'] = FALSE; } return $element; } diff --git a/core/modules/layout_builder/src/Plugin/Block/InlineBlockTranslationForm.php b/core/modules/layout_builder/src/Plugin/Block/InlineBlockTranslationForm.php index c8a331ce2c..7e4fb66965 100644 --- a/core/modules/layout_builder/src/Plugin/Block/InlineBlockTranslationForm.php +++ b/core/modules/layout_builder/src/Plugin/Block/InlineBlockTranslationForm.php @@ -89,7 +89,7 @@ protected function getEntity() { public function buildConfigurationForm(array $form, FormStateInterface $form_state) { $form = parent::buildConfigurationForm($form, $form_state); $block = $this->getEntity(); - + if ($block->isTranslatable()) { // Add the entity form display in a process callback so that #parents can // be successfully propagated to field widgets. $form['block_form'] = [ @@ -97,7 +97,7 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta '#process' => [[static::class, 'processBlockForm']], '#block' => $block, ]; - + } return $form; } @@ -115,6 +115,9 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta public static function processBlockForm(array $element, FormStateInterface $form_state) { /** @var \Drupal\block_content\BlockContentInterface $block */ $block = $element['#block']; + // @todo (in this issue) Look at how ContentTranslationController creates + // the add/edit translation forms and determine if we need to implement + // the same logic. EntityFormDisplay::collectRenderDisplay($block, 'edit')->buildForm($block, $element, $form_state); $element['revision_log']['#access'] = FALSE; $element['info']['#access'] = FALSE; @@ -127,6 +130,7 @@ public static function processBlockForm(array $element, FormStateInterface $form */ public function validateConfigurationForm(array &$form, FormStateInterface $form_state) { parent::validateConfigurationForm($form, $form_state); + if (!empty($form['block_form'])) { $block_form = $form['block_form']; /** @var \Drupal\block_content\BlockContentInterface $block */ $block = $block_form['#block']; @@ -138,13 +142,15 @@ public function validateConfigurationForm(array &$form, FormStateInterface $form $form_state->setTemporaryValue('block_form_parents', $block_form['#parents']); } + } + /** * {@inheritdoc} */ public function submitConfigurationForm(array &$form, FormStateInterface $form_state) { parent::submitConfigurationForm($form, $form_state); - $configuration = $this->plugin->getConfiguration(); + if (!empty($form['settings']['block_form'])) { // @todo Remove when https://www.drupal.org/project/drupal/issues/2948549 is closed. $block_form = NestedArray::getValue($form, $form_state->getTemporaryValue('block_form_parents')); /** @var \Drupal\block_content\BlockContentInterface $block */ @@ -153,8 +159,10 @@ public function submitConfigurationForm(array &$form, FormStateInterface $form_s $complete_form_state = $form_state instanceof SubformStateInterface ? $form_state->getCompleteFormState() : $form_state; $form_display->extractFormValues($block, $block_form, $complete_form_state); + $configuration = $this->plugin->getConfiguration(); $configuration['block_serialized'] = serialize($block); $this->plugin->setConfiguration($configuration); } + } }