You are here

public function ConfigForm::validateForm in Menu Link Attributes 8

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/Form/ConfigForm.php, line 121

Class

ConfigForm
Class ConfigForm.

Namespace

Drupal\menu_link_attributes\Form

Code

public function validateForm(array &$form, FormStateInterface $form_state) {
  $config_text = $form_state
    ->getValue('config') ?: 'attributes:';
  try {
    $form_state
      ->set('config', Yaml::decode($config_text));
  } catch (InvalidDataTypeException $e) {
    $form_state
      ->setErrorByName('config', $e
      ->getMessage());
  }
  parent::validateForm($form, $form_state);
}