public function ConfigForm::validateForm in Block 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 90 - Contains Drupal\block_attributes\Form\ConfigForm.
Class
- ConfigForm
- Class ConfigForm.
Namespace
Drupal\block_attributes\FormCode
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);
}