You are here

public function LogRescheduleActionForm::validateForm in Log entity 2.x

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/LogRescheduleActionForm.php, line 106

Class

LogRescheduleActionForm
Provides a log reschedule confirmation form.

Namespace

Drupal\log\Form

Code

public function validateForm(array &$form, FormStateInterface $form_state) {
  $type_of_date = $form_state
    ->getValue('type_of_date');
  if ($type_of_date) {
    $amount = $form_state
      ->getValue('amount');
    $time = $form_state
      ->getValue('time');
    if (empty($amount)) {
      $form_state
        ->setError($form['relative']['amount'], 'Please enter the amount of time for rescheduling.');
    }
    if (empty($time)) {
      $form_state
        ->setError($form['relative']['amount'], 'Please enter the time units for rescheduling.');
    }
  }
}