You are here

public function FormTestVerticalTabsAccessForm::buildForm in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/system/tests/modules/form_test/src/Form/FormTestVerticalTabsAccessForm.php \Drupal\form_test\Form\FormTestVerticalTabsAccessForm::buildForm()
  2. 10 core/modules/system/tests/modules/form_test/src/Form/FormTestVerticalTabsAccessForm.php \Drupal\form_test\Form\FormTestVerticalTabsAccessForm::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

core/modules/system/tests/modules/form_test/src/Form/FormTestVerticalTabsAccessForm.php, line 25

Class

FormTestVerticalTabsAccessForm
Builds a form to test vertical tabs access.

Namespace

Drupal\form_test\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $form['vertical_tabs1'] = [
    '#type' => 'vertical_tabs',
  ];
  $form['tab1'] = [
    '#type' => 'fieldset',
    '#title' => t('Tab 1'),
    '#collapsible' => TRUE,
    '#group' => 'vertical_tabs1',
  ];
  $form['tab1']['field1'] = [
    '#title' => t('Field 1'),
    '#type' => 'checkbox',
    '#default_value' => TRUE,
  ];
  $form['tab2'] = [
    '#type' => 'fieldset',
    '#title' => t('Tab 2'),
    '#collapsible' => TRUE,
    '#group' => 'vertical_tabs1',
  ];
  $form['tab2']['field2'] = [
    '#title' => t('Field 2'),
    '#type' => 'textfield',
    '#default_value' => 'field2',
  ];
  $form['fieldset1'] = [
    '#type' => 'fieldset',
    '#title' => t('Fieldset'),
  ];
  $form['fieldset1']['field3'] = [
    '#type' => 'checkbox',
    '#title' => t('Field 3'),
    '#default_value' => TRUE,
  ];
  $form['container'] = [
    '#type' => 'container',
  ];
  $form['container']['field4'] = [
    '#type' => 'checkbox',
    '#title' => t('Field 4'),
    '#default_value' => TRUE,
  ];
  $form['container']['subcontainer'] = [
    '#type' => 'container',
  ];
  $form['container']['subcontainer']['field5'] = [
    '#type' => 'checkbox',
    '#title' => t('Field 5'),
    '#default_value' => TRUE,
  ];
  $form['vertical_tabs2'] = [
    '#type' => 'vertical_tabs',
  ];
  $form['tab3'] = [
    '#type' => 'fieldset',
    '#title' => t('Tab 3'),
    '#collapsible' => TRUE,
    '#group' => 'vertical_tabs2',
  ];
  $form['tab3']['field6'] = [
    '#title' => t('Field 6'),
    '#type' => 'checkbox',
    '#default_value' => TRUE,
  ];
  $form['actions'] = [
    '#type' => 'actions',
  ];
  $form['actions']['submit'] = [
    '#type' => 'submit',
    '#value' => t('Submit'),
  ];
  return $form;
}