You are here

public function Crontab::validateConfigurationForm in Ultimate Cron 8.2

Form validation handler.

Parameters

array $form: An associative array containing the structure of the plugin form as built by static::buildConfigurationForm().

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form. Calling code should pass on a subform state created through \Drupal\Core\Form\SubformState::createForSubform().

Overrides CronPlugin::validateConfigurationForm

File

src/Plugin/ultimate_cron/Scheduler/Crontab.php, line 104

Class

Crontab
Crontab scheduler.

Namespace

Drupal\ultimate_cron\Plugin\ultimate_cron\Scheduler

Code

public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {
  parent::validateConfigurationForm($form, $form_state);
  $rule = $form_state
    ->getValues()['scheduler']['configuration']['rules'][0];
  $cron = CronRule::factory($rule);
  if (!$cron
    ->isValid()) {
    $form_state
      ->setErrorByName('scheduler][configuration][rules][0', t('Rule is invalid'));
  }
}