function BlockForm::submitForm

Same name in other branches
  1. 9 core/modules/block/src/BlockForm.php \Drupal\block\BlockForm::submitForm()
  2. 8.9.x core/modules/block/src/BlockForm.php \Drupal\block\BlockForm::submitForm()
  3. 11.x core/modules/block/src/BlockForm.php \Drupal\block\BlockForm::submitForm()

Overrides EntityForm::submitForm

File

core/modules/block/src/BlockForm.php, line 339

Class

BlockForm
Provides form for block instance forms.

Namespace

Drupal\block

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
    parent::submitForm($form, $form_state);
    $entity = $this->entity;
    // The Block Entity form puts all block plugin form elements in the
    // settings form element, so just pass that to the block for submission.
    $sub_form_state = SubformState::createForSubform($form['settings'], $form, $form_state);
    // Call the plugin submit handler.
    $block = $entity->getPlugin();
    $this->getPluginForm($block)
        ->submitConfigurationForm($form, $sub_form_state);
    // If this block is context-aware, set the context mapping.
    if ($block instanceof ContextAwarePluginInterface && $block->getContextDefinitions()) {
        $context_mapping = $sub_form_state->getValue('context_mapping', []);
        $block->setContextMapping($context_mapping);
    }
    $this->submitVisibility($form, $form_state);
}

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