You are here

protected function OverridesEntityForm::init in Layout Builder Symmetric Translations 8

Initializes the form state and the entity before the first form build.

Parameters

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Overrides OverridesEntityForm::init

File

src/Form/OverridesEntityForm.php, line 31

Class

OverridesEntityForm
Extended OverridesEntityForm

Namespace

Drupal\layout_builder_st\Form

Code

protected function init(FormStateInterface $form_state) {
  parent::init($form_state);
  $field_name = static::isTranslation($this->sectionStorage) ? OverridesSectionStorage::TRANSLATED_CONFIGURATION_FIELD_NAME : OverridesSectionStorage::FIELD_NAME;
  if ($field_name === OverridesSectionStorage::TRANSLATED_CONFIGURATION_FIELD_NAME) {
    $form_display = $this
      ->getFormDisplay($form_state);
    $form_display
      ->removeComponent(OverridesSectionStorage::FIELD_NAME);
    $form_display
      ->setComponent($field_name, [
      'type' => 'layout_builder_widget',
      'weight' => -10,
      'settings' => [],
    ]);
    $this
      ->setFormDisplay($form_display, $form_state);
  }
}