You are here

public function DashboardBlockFormBase::submitForm in Draggable dashboard 8.2

Parameters

array $form:

\Drupal\Core\Form\FormStateInterface $form_state:

Throws

\Drupal\Core\Entity\EntityStorageException

Overrides FormInterface::submitForm

2 calls to DashboardBlockFormBase::submitForm()
DashboardAssignBlockForm::submitForm in src/Form/DashboardAssignBlockForm.php
DashboardConfigureBlockForm::submitForm in src/Form/DashboardConfigureBlockForm.php
Form submission handler.
2 methods override DashboardBlockFormBase::submitForm()
DashboardAssignBlockForm::submitForm in src/Form/DashboardAssignBlockForm.php
DashboardConfigureBlockForm::submitForm in src/Form/DashboardConfigureBlockForm.php
Form submission handler.

File

src/Form/DashboardBlockFormBase.php, line 166

Class

DashboardBlockFormBase
Class DashboardBlockFormBase

Namespace

Drupal\draggable_dashboard\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {

  // Save block entity.
  $block = $this->blockManager
    ->createInstance($this->block['settings']['id']);
  $subform_state = SubformState::createForSubform($form['settings'], $form_state
    ->getCompleteForm(), $form_state);
  $block
    ->submitConfigurationForm($form['settings'], $subform_state);

  // If this block is context-aware, set the context mapping.
  if ($block instanceof ContextAwarePluginInterface && $block
    ->getContextDefinitions()) {
    $context_mapping = $subform_state
      ->getValue('context_mapping', []);
    $block
      ->setContextMapping($context_mapping);
  }
  $settings = $block
    ->getConfiguration();
  $form_state
    ->setValue('settings', $settings);
}