You are here

public function CronExampleForm::submitForm in Examples for Developers 8

Same name and namespace in other branches
  1. 3.x modules/cron_example/src/Form/CronExampleForm.php \Drupal\cron_example\Form\CronExampleForm::submitForm()

Form submission 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 ConfigFormBase::submitForm

File

cron_example/src/Form/CronExampleForm.php, line 238

Class

CronExampleForm
Form with examples on how to use cron.

Namespace

Drupal\cron_example\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {

  // Update the interval as stored in configuration. This will be read when
  // this modules hook_cron function fires and will be used to ensure that
  // action is taken only after the appropiate time has elapsed.
  $this
    ->config('cron_example.settings')
    ->set('interval', $form_state
    ->getValue('cron_example_interval'))
    ->save();
  parent::submitForm($form, $form_state);
}