You are here

public function TestLayoutFormWithValidation::validateConfigurationForm in Layout Builder UX 8

Form validation handler.

Parameters

array $form: An associative array containing the structure of the plugin form as built by static::buildConfigurationForm().

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form. Calling code should pass on a subform state created through \Drupal\Core\Form\SubformState::createForSubform().

Overrides LayoutDefault::validateConfigurationForm

File

tests/modules/lb_ux_test/src/Plugin/Layout/TestLayoutFormWithValidation.php, line 26

Class

TestLayoutFormWithValidation
Provides a test layout that always adds a status message.

Namespace

Drupal\lb_ux_test\Plugin\Layout

Code

public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {
  parent::validateConfigurationForm($form, $form_state);
  if ($form_state
    ->getValue('label') !== 'Abracadabra') {
    $form_state
      ->setErrorByName('label', "That's not the magic word!");
  }
}