You are here

public function ContentDelete::buildForm in Delete all 8

Same name and namespace in other branches
  1. 2.x src/Form/ContentDelete.php \Drupal\delete_all\Form\ContentDelete::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/ContentDelete.php, line 44

Class

ContentDelete
Create a Form for deleting all content.

Namespace

Drupal\delete_all\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $form['select_all'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Delete All Type'),
    '#description' => $this
      ->t('Delete all content of all type'),
  ];
  $form['type_details'] = [
    '#type' => 'details',
    '#title' => $this
      ->t('Node types'),
    '#description' => $this
      ->t('Select the types of node content to delete'),
    '#open' => TRUE,
    '#states' => [
      'visible' => [
        ':input[name="select_all"]' => [
          'checked' => FALSE,
        ],
      ],
    ],
  ];
  $form['type_details']['node_type'] = [
    '#type' => 'select',
    '#title' => $this
      ->t('Select The Node Type'),
    '#options' => $this
      ->getAvailableNodeType(),
    '#states' => [
      'visible' => [
        ':input[name="select_all"]' => [
          'checked' => FALSE,
        ],
      ],
    ],
  ];
  $form['submit'] = [
    '#type' => 'submit',
    '#value' => $this
      ->t('Delete'),
  ];
  return $form;
}