function LayoutRebuildConfirmFormBase::buildForm

Same name and namespace in other branches
  1. 9 core/modules/layout_builder/src/Form/LayoutRebuildConfirmFormBase.php \Drupal\layout_builder\Form\LayoutRebuildConfirmFormBase::buildForm()
  2. 8.9.x core/modules/layout_builder/src/Form/LayoutRebuildConfirmFormBase.php \Drupal\layout_builder\Form\LayoutRebuildConfirmFormBase::buildForm()
  3. 10 core/modules/layout_builder/src/Form/LayoutRebuildConfirmFormBase.php \Drupal\layout_builder\Form\LayoutRebuildConfirmFormBase::buildForm()

Overrides ConfirmFormBase::buildForm

1 call to LayoutRebuildConfirmFormBase::buildForm()
RemoveBlockForm::buildForm in core/modules/layout_builder/src/Form/RemoveBlockForm.php
Form constructor.
1 method overrides LayoutRebuildConfirmFormBase::buildForm()
RemoveBlockForm::buildForm in core/modules/layout_builder/src/Form/RemoveBlockForm.php
Form constructor.

File

core/modules/layout_builder/src/Form/LayoutRebuildConfirmFormBase.php, line 78

Class

LayoutRebuildConfirmFormBase
Provides a base class for confirmation forms that rebuild the Layout Builder.

Namespace

Drupal\layout_builder\Form

Code

public function buildForm(array $form, FormStateInterface $form_state, ?SectionStorageInterface $section_storage = NULL, $delta = NULL) {
    $this->sectionStorage = $section_storage;
    $this->delta = $delta;
    $form = parent::buildForm($form, $form_state);
    if ($this->isAjax()) {
        $form['actions']['submit']['#ajax']['callback'] = '::ajaxSubmit';
        $form['actions']['cancel']['#attributes']['class'][] = 'dialog-cancel';
        $target_highlight_id = !empty($this->uuid) ? $this->blockUpdateHighlightId($this->uuid) : $this->sectionUpdateHighlightId($delta);
        $form['#attributes']['data-layout-builder-target-highlight-id'] = $target_highlight_id;
        // The AJAX system automatically moves focus to the first tabbable
        // element after closing a dialog, sometimes scrolling to a page top.
        // Disable refocus on the button.
        $form['actions']['submit']['#ajax']['disable-refocus'] = TRUE;
    }
    // Mark this as an administrative page for JavaScript ("Back to site" link).
    $form['#attached']['drupalSettings']['path']['currentPathIsAdmin'] = TRUE;
    return $form;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.