Skip to content
Snippets Groups Projects
Commit 6fa0c888 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #1434670 by AlPotapov, bleen18 | ericduran: Add test for verticle_tabs default.

parent 8b246745
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
......@@ -58,4 +58,12 @@ function testWrapperNotShownWhenEmpty() {
$wrapper = $this->xpath("//div[@data-vertical-tabs-panes]");
$this->assertFalse(isset($wrapper[0]), 'Vertical tab wrappers are not displayed to unprivileged users.');
}
/**
* Ensures that default vertical tab is correctly selected.
*/
function testDefaultTab() {
$this->drupalGet('form_test/vertical-tabs');
$this->assertFieldByName('vertical_tabs__active_tab', 'edit-tab3', t('The default vertical tab is correctly selected.'));
}
}
......@@ -23,29 +23,26 @@ public function getFormId() {
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
$tab_count = 3;
$form['vertical_tabs'] = array(
'#type' => 'vertical_tabs',
'#default_tab' => 'edit-tab' . $tab_count,
);
$form['tab1'] = array(
'#type' => 'details',
'#title' => t('Tab 1'),
'#group' => 'vertical_tabs',
'#access' => \Drupal::currentUser()->hasPermission('access vertical_tab_test tabs'),
);
$form['tab1']['field1'] = array(
'#title' => t('Field 1'),
'#type' => 'textfield',
);
$form['tab2'] = array(
'#type' => 'details',
'#title' => t('Tab 2'),
'#group' => 'vertical_tabs',
'#access' => \Drupal::currentUser()->hasPermission('access vertical_tab_test tabs'),
);
$form['tab2']['field2'] = array(
'#title' => t('Field 2'),
'#type' => 'textfield',
);
for ($i = 1; $i <= $tab_count; $i++) {
$form['tab' . $i] = array(
'#type' => 'fieldset',
'#title' => t('Tab !num', array('!num' => $i)),
'#group' => 'vertical_tabs',
'#access' => \Drupal::currentUser()->hasPermission('access vertical_tab_test tabs'),
);
$form['tab' . $i]['field' . $i] = array(
'#title' => t('Field !num', array('!num' => $i)),
'#type' => 'textfield',
);
}
return $form;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment