You are here

public function BlockFormBase::validateForm in Context 8.4

Form validation 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 FormBase::validateForm

File

src/Reaction/Blocks/Form/BlockFormBase.php, line 305

Class

BlockFormBase
Provides a Block Form Base for blocks reactions.

Namespace

Drupal\context\Reaction\Blocks\Form

Code

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);
  }
}