You are here

public function SmartDateFormatForm::validateForm in Smart Date 8

Same name and namespace in other branches
  1. 8.2 src/Form/SmartDateFormatForm.php \Drupal\smart_date\Form\SmartDateFormatForm::validateForm()
  2. 3.x src/Form/SmartDateFormatForm.php \Drupal\smart_date\Form\SmartDateFormatForm::validateForm()
  3. 3.0.x src/Form/SmartDateFormatForm.php \Drupal\smart_date\Form\SmartDateFormatForm::validateForm()
  4. 3.1.x src/Form/SmartDateFormatForm.php \Drupal\smart_date\Form\SmartDateFormatForm::validateForm()
  5. 3.2.x src/Form/SmartDateFormatForm.php \Drupal\smart_date\Form\SmartDateFormatForm::validateForm()
  6. 3.3.x src/Form/SmartDateFormatForm.php \Drupal\smart_date\Form\SmartDateFormatForm::validateForm()
  7. 3.4.x src/Form/SmartDateFormatForm.php \Drupal\smart_date\Form\SmartDateFormatForm::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/SmartDateFormatForm.php, line 197

Class

SmartDateFormatForm
Form controller for smart date format edit forms.

Namespace

Drupal\smart_date\Form

Code

public function validateForm(array &$form, FormStateInterface $form_state) {
  parent::validateForm($form, $form_state);
  if (empty($form_state
    ->getValue('time_format')) && empty($form_state
    ->getValue('date_format'))) {
    $form_state
      ->setErrorByName('time_format', $this
      ->t('Please specify either the time format or the date format.'));
  }
}