You are here

public function PeopleDelete::buildForm in Delete all 8

Same name and namespace in other branches
  1. 2.x src/Form/PeopleDelete.php \Drupal\delete_all\Form\PeopleDelete::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 FormInterface::buildForm

File

src/Form/PeopleDelete.php, line 44

Class

PeopleDelete
Form for user deleting option.

Namespace

Drupal\delete_all\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $form['select_all'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Delete all Users (Authenticated User)'),
    '#description' => $this
      ->t('Delete all Users with any type of Role (except the uid = 1)'),
  ];
  $form['role_details'] = [
    '#type' => 'details',
    '#title' => $this
      ->t('Role types'),
    '#description' => $this
      ->t('Select the types of role user to delete'),
    '#open' => TRUE,
    '#states' => [
      'visible' => [
        ':input[name="select_all"]' => [
          'checked' => FALSE,
        ],
      ],
    ],
  ];
  $form['role_details']['role_type'] = [
    '#type' => 'select',
    '#title' => $this
      ->t('Select The Role Type'),
    '#options' => $this
      ->getAvailableRoleType(),
    '#states' => [
      'visible' => [
        ':input[name="select_all"]' => [
          'checked' => FALSE,
        ],
      ],
    ],
  ];
  $form['submit'] = [
    '#type' => 'submit',
    '#value' => $this
      ->t('Delete'),
  ];
  return $form;
}