You are here

public function SettingsForm::buildForm in Content locking (anti-concurrent editing) 8

Same name and namespace in other branches
  1. 8.2 modules/content_lock_timeout/src/Form/SettingsForm.php \Drupal\content_lock_timeout\Form\SettingsForm::buildForm()

Form constructor.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Return value

array The form structure.

Overrides ConfigFormBase::buildForm

File

modules/content_lock_timeout/src/Form/SettingsForm.php, line 36

Class

SettingsForm
Class SettingsForm.

Namespace

Drupal\content_lock_timeout\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $config = $this
    ->config('content_lock_timeout.settings');
  $form['content_lock_timeout'] = [
    '#type' => 'fieldset',
    '#title' => $this
      ->t('Lock Timeouts'),
    '#description' => $this
      ->t('Configure automatic stale lock breaking.'),
  ];
  $form['content_lock_timeout']['content_lock_timeout_minutes'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Lock timeout'),
    '#description' => $this
      ->t('The maximum time in minutes that each lock may be kept. To disable breaking locks after a timeout, please %disable the Content Lock Timeout module.', [
      '%disable' => Link::fromTextAndUrl($this
        ->t('disable'), Url::fromRoute('system.modules_list'))
        ->toString(),
    ]),
    '#maxlength' => 64,
    '#size' => 64,
    '#default_value' => $config
      ->get('content_lock_timeout_minutes'),
  ];
  $form['content_lock_timeout']['content_lock_timeout_on_edit'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Break stale locks on edit'),
    '#description' => $this
      ->t("By default, stale locks will be broken when cron is run. This option enables checking for stale locks when a user clicks a node's Edit link, enabling lower lock timeout values without having to run cron every few minutes."),
    '#default_value' => $config
      ->get('content_lock_timeout_on_edit'),
  ];
  return parent::buildForm($form, $form_state);
}