public function BlockFieldForm::submitForm in Display Suite 8.2
Same name and namespace in other branches
- 8.4 src/Form/BlockFieldForm.php \Drupal\ds\Form\BlockFieldForm::submitForm()
- 8.3 src/Form/BlockFieldForm.php \Drupal\ds\Form\BlockFieldForm::submitForm()
Form submission handler.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Overrides FieldFormBase::submitForm
File
- src/
Form/ BlockFieldForm.php, line 98
Class
- BlockFieldForm
- Configure block fields.
Namespace
Drupal\ds\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
parent::submitForm($form, $form_state);
// Create an instance of the block to find out if it has a config form.
// Redirect to the block config form if there is one.
/* @var $block BlockPluginInterface */
$manager = \Drupal::service('plugin.manager.block');
$block_id = $this->field['properties']['block'];
$block = $manager
->createInstance($block_id);
$block_config_form = $block
->blockForm([], new FormState());
if ($block_config_form) {
$url = new Url('ds.manage_block_field_config', array(
'field_key' => $this->field['id'],
));
$form_state
->setRedirectUrl($url);
}
// Invalidate all blocks
Cache::invalidateTags([
'config:ds.block_base',
]);
}