You are here

public function ConfigForm::validateForm in Linked Field 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 123

Class

ConfigForm
Class ConfigForm.

Namespace

Drupal\linked_field\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);
}