Commit 6fa0c888 authored by alexpott's avatar alexpott

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

parent 8b246745
......@@ -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;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment