You are here

public function BetterRevisionsAdminForm::buildForm in Better Revisions 8

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

src/Form/BetterRevisionsAdminForm.php, line 32

Class

BetterRevisionsAdminForm
Administration form for Better Revisions module.

Namespace

Drupal\better_revisions\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $config = $this
    ->config('better_revisions.settings');
  $form['br_require'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Require revision type selection'),
    '#default_value' => $config
      ->get('br_require'),
    '#description' => $this
      ->t('Will only be required if <em>Create new revision</em> is checked.'),
  ];
  $form['br_list_title'] = [
    '#type' => 'textfield',
    '#title' => 'Revision list title',
    '#default_value' => $config
      ->get('br_list_title'),
    '#required' => TRUE,
  ];
  $form['br_list_options'] = [
    '#type' => 'textarea',
    '#title' => 'Revision list options',
    '#default_value' => $config
      ->get('br_list_options'),
    '#required' => TRUE,
    '#description' => $this
      ->t('Enter options, one per line'),
  ];
  $form['br_list_help'] = [
    '#type' => 'textfield',
    '#title' => 'Revision list help text',
    '#default_value' => $config
      ->get('br_list_help'),
  ];
  $form['br_add_txt'] = [
    '#type' => 'radios',
    '#title' => $this
      ->t('Add an open text area for revision notes'),
    '#default_value' => $config
      ->get('br_add_txt'),
    '#options' => [
      0 => $this
        ->t('No'),
      1 => $this
        ->t('Yes (optional)'),
      2 => $this
        ->t('Yes (required)'),
    ],
  ];
  $form['br_area_title'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Title for the revision notes box'),
    '#default_value' => $config
      ->get('br_area_title'),
    '#states' => [
      'visible' => [
        [
          ':input[name="br_add_txt"]' => [
            'value' => 1,
          ],
        ],
        [
          ':input[name="br_add_txt"]' => [
            'value' => 2,
          ],
        ],
      ],
    ],
  ];
  return parent::buildForm($form, $form_state);
}