public function DateRecurModularSierraModalForm::validateForm in Recurring Date Field Modular Widgets 8
Same name and namespace in other branches
- 3.x src/Form/DateRecurModularSierraModalForm.php \Drupal\date_recur_modular\Form\DateRecurModularSierraModalForm::validateForm()
- 2.x src/Form/DateRecurModularSierraModalForm.php \Drupal\date_recur_modular\Form\DateRecurModularSierraModalForm::validateForm()
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/ DateRecurModularSierraModalForm.php, line 277
Class
- DateRecurModularSierraModalForm
- Generate a form designed for display in modal.
Namespace
Drupal\date_recur_modular\FormCode
public function validateForm(array &$form, FormStateInterface $form_state) {
$endsMode = $form_state
->getValue('ends_mode');
/** @var \Drupal\Core\Datetime\DrupalDateTime|array|null $endsDate */
$endsDate = $form_state
->getValue('ends_date');
if ('date' === $endsMode && !$endsDate instanceof DrupalDateTime) {
// Prevent submission, if for example only date provided (missing time).
$form_state
->setError($form['ends']['ends_date'], $this
->t('Invalid date.'));
}
}