Commit 54b5f8dd authored by git's avatar git Committed by paulocs

Issue #2977443 by George Bills, nace_fric: Custom block blockValidate does not...

Issue #2977443 by George Bills, nace_fric: Custom block blockValidate does not fire when placed in context
parent 5e6e4556
......@@ -258,6 +258,28 @@ abstract class BlockFormBase extends FormBase {
return $form;
}
/**
* Form validation handler.
*
* @param array $form
* An associative array containing the structure of the form.
*
* @param \Drupal\Core\Form\FormStateInterface $form_state
* The current state of the form.
*/
public function validateForm(array &$form, FormStateInterface $form_state) {
$settings = (new FormState())->setValues($form_state->getValue('settings'));
// Call the plugin validate handler.
$this->block->validateConfigurationForm($form['settings'], $settings);
// Update the original form values, including errors.
$form_state->setValue('settings', $settings->getValues());
foreach ($settings->getErrors() as $name => $error) {
$form_state->setErrorByName($name, $error);
}
}
/**
* Form submission handler.
*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment