You are here

public function ProtectedPagesAddForm::buildForm in Protected Pages 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 FormInterface::buildForm

File

src/Form/ProtectedPagesAddForm.php, line 100

Class

ProtectedPagesAddForm
Provides an add protected page form.

Namespace

Drupal\protected_pages\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $form['rules_list'] = [
    '#title' => $this
      ->t('Add Protected Page relative path and password.'),
    '#type' => 'details',
    '#description' => $this
      ->t('Please enter the relative path and its corresponding
    password. When user opens this url, they will asked to enter password to
    view this page. For example, "/node/5", "/new-events" etc.'),
    '#open' => TRUE,
  ];
  $form['rules_list']['path'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Relative path'),
    '#description' => $this
      ->t('Enter relative Drupal path. For example, "/node/5", "new-events" etc.'),
    '#required' => TRUE,
  ];
  $form['rules_list']['password'] = [
    '#type' => 'password_confirm',
    '#size' => 25,
    '#required' => TRUE,
  ];
  $form['rules_list']['submit'] = [
    '#type' => 'submit',
    '#value' => $this
      ->t('Save'),
  ];
  return $form;
}