public function WebformSanitizeConfigForm::buildForm in Webform Scheduled Tasks 8
Parameters
array $form: The parameters to use to work out the value.
\Drupal\Core\Form\FormStateInterface $form_state: The parameters to use to work out the value.
Return value
array The form definition.
Overrides ConfigFormBase::buildForm
File
- src/
Form/ WebformSanitizeConfigForm.php, line 24
Class
- WebformSanitizeConfigForm
- Webform Sanitize config form.
Namespace
Drupal\webform_scheduled_tasks\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
$config = $this
->configFactory()
->get('webform_scheduled_tasks.config');
$form['description'] = [
'#markup' => $this
->t('Use this form to configure Webform Scheduled Tasks.'),
'#prefix' => '<p>',
'#suffix' => '</p>',
];
$form['settings'] = [
'#type' => 'details',
'#tree' => TRUE,
'#open' => TRUE,
'#title' => $this
->t('Webform Scheduled Tasks Settings'),
];
$form['settings']['description'] = [
'#markup' => $this
->t('This is a scheduled job that runs every "x" minutes and is designed to sanitize a specified Webform field.'),
'#prefix' => '<p>',
'#suffix' => '</p>',
];
$form['settings']['field_name'] = [
'#type' => 'textfield',
'#title' => $this
->t('Field Name'),
'#description' => $this
->t('Provide the Field be sanitized.'),
'#default_value' => $config
->get("field_name"),
'#required' => TRUE,
];
$form['settings']['sanitized_value'] = [
'#type' => 'textfield',
'#title' => $this
->t('Sanitized Value'),
'#description' => $this
->t('Provide the value to overwrite the Field with.'),
'#default_value' => $config
->get("sanitized_value"),
'#required' => TRUE,
];
$form['settings']['run_interval'] = [
'#type' => 'textfield',
'#title' => $this
->t('Run Interval'),
'#description' => $this
->t('Set the interval in minutes between runs. Default 1440 (24 hours).'),
'#default_value' => $config
->get("run_interval"),
'#required' => TRUE,
];
$form['settings']['last_run'] = [
'#markup' => $this
->t('Last Run: @last_run', [
'@last_run' => $config
->get("last_run"),
]),
'#prefix' => '<p>',
'#suffix' => '</p>',
];
$form['settings']['manual'] = [
'#type' => 'submit',
'#value' => $this
->t('Save and Run Webform Sanitization'),
'#submit' => [
[
$this,
'submitForm',
],
'webform_scheduled_tasks_do_actions',
],
];
return parent::buildForm($form, $form_state);
}