public function jQueryUiFilterSettingsForm::validateForm in jQuery UI filter 8.2
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/ jQueryUiFilterSettingsForm.php, line 86 - Contains \Drupal\jquery_ui_filter\Form\jQueryUiFilterSettingsForm.
Class
- jQueryUiFilterSettingsForm
- Defines a form that configures jQuery UI filter settings.
Namespace
Drupal\jquery_ui_filter\FormCode
public function validateForm(array &$form, FormStateInterface $form_state) {
$data = $form_state
->getValue('jquery_ui_filter');
foreach (jQueryUiFilter::$widgets as $name => $label) {
try {
Yaml::decode($data[$name]['options']);
} catch (\Exception $exception) {
$message = [
'message' => [
'#markup' => t('%title is not valid.', [
'%title' => $label,
]),
],
'errors' => [
'#theme' => 'item_list',
'#items' => [
$exception
->getMessage(),
],
],
];
$form_state
->setError($form['jquery_ui_filter'][$name]['options'], $message);
}
}
}