public function GeneralSettingsForm::validateForm in Diff 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/ GeneralSettingsForm.php, line 209
Class
- GeneralSettingsForm
- Configure global diff settings.
Namespace
Drupal\diff\FormCode
public function validateForm(array &$form, FormStateInterface $form_state) {
parent::validateForm($form, $form_state);
// Make sure there is at least one layout enabled.
$enabled_layouts = [];
foreach ($form_state
->getValue('layout_plugins') as $key => $layout) {
if ($layout['enabled']) {
$enabled_layouts[] = $key;
}
}
if (!$enabled_layouts) {
$form_state
->setErrorByName('layout_plugins', t('At least one layout plugin needs to be enabled.'));
}
}