function FormTestVerticalTabsForm::buildForm
Same name in other branches
- 9 core/modules/system/tests/modules/form_test/src/Form/FormTestVerticalTabsForm.php \Drupal\form_test\Form\FormTestVerticalTabsForm::buildForm()
- 8.9.x core/modules/system/tests/modules/form_test/src/Form/FormTestVerticalTabsForm.php \Drupal\form_test\Form\FormTestVerticalTabsForm::buildForm()
- 10 core/modules/system/tests/modules/form_test/src/Form/FormTestVerticalTabsForm.php \Drupal\form_test\Form\FormTestVerticalTabsForm::buildForm()
Overrides FormInterface::buildForm
File
-
core/
modules/ system/ tests/ modules/ form_test/ src/ Form/ FormTestVerticalTabsForm.php, line 28
Class
- FormTestVerticalTabsForm
- Builds a simple form to test vertical tabs.
Namespace
Drupal\form_test\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
$tab_count = 3;
$form['vertical_tabs'] = [
'#type' => 'vertical_tabs',
'#default_tab' => 'edit-tab' . $tab_count,
];
for ($i = 1; $i <= $tab_count; $i++) {
$form['tab' . $i] = [
'#type' => 'fieldset',
'#title' => $this->t('Tab @num', [
'@num' => $i,
]),
'#group' => 'vertical_tabs',
'#access' => \Drupal::currentUser()->hasPermission('access vertical_tab_test tabs'),
];
$form['tab' . $i]['field' . $i] = [
'#title' => $this->t('Field @num', [
'@num' => $i,
]),
'#type' => 'textfield',
];
}
return $form;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.