function SystemStateEdit::validateForm
Same name in other branches
- 4.x src/Form/SystemStateEdit.php \Drupal\devel\Form\SystemStateEdit::validateForm()
- 5.x src/Form/SystemStateEdit.php \Drupal\devel\Form\SystemStateEdit::validateForm()
File
-
src/
Form/ SystemStateEdit.php, line 129
Class
- SystemStateEdit
- Form API form to edit a state.
Namespace
Drupal\devel\FormCode
public function validateForm(array &$form, FormStateInterface $form_state) {
$values = $form_state->getValues();
if ($values['transport'] == 'yaml') {
// try to parse the new provided value
try {
$parsed_value = Yaml::decode($values['new_value']);
$form_state->setValue('parsed_value', $parsed_value);
} catch (InvalidDataTypeException $e) {
$form_state->setErrorByName('new_value', $this->t('Invalid input: %error', array(
'%error' => $e->getMessage(),
)));
}
}
else {
$form_state->setValue('parsed_value', $values['new_value']);
}
}