Closed (fixed)
Project:
Javascript Tools
Version:
master
Component:
Tabs
Priority:
Normal
Category:
Task
Assigned:
Reporter:
Created:
4 Mar 2007 at 04:22 UTC
Updated:
27 Mar 2007 at 03:00 UTC
Tabs are currently generated only partially through the forms api. It would be better to generate them fully through the forms api, so that developers could use tabs seamlessly in forms.
Attached patch does this. It will necessitate changes in how tabs are generated. Old way:
$tabs = array(
'#name' => 'example1',
);
$tabs[] = array(
'#title' => t('One'),
'#content' => t('First tab content.'),
);
$tabs[] = array(
'#title' => t('Two'),
'#content' => t('Second tab content.'),
);
$tabs[] = array(
'#title' => t('Three'),
'#content' => t('Third tab content.'),
);
return theme('tabs_tabset', $tabs);
New way:
$form = array();
$form['example1'] = array(
'#type' => 'tabset',
);
$form['example1']['tab1'] = array(
'#type' => 'tabpage',
'#title' => t('One'),
'#content' => t('First tab content.'),
);
$form['example1']['tab2'] = array(
'#type' => 'tabpage',
'#title' => t('Two'),
'#content' => t('Second tab content.'),
);
$form['example1']['tab3'] = array(
'#type' => 'tabpage',
'#title' => t('Three'),
'#content' => t('Third tab content.'),
);
The patch also includes an example module implementing tabs.
| Comment | File | Size | Author |
|---|---|---|---|
| tabs-forms-api.patch | 6.29 KB | nedjo |
Comments
Comment #1
zigma commentedThis seems interesting.
Just wondering on its impact. I guess it will not constrain building tabs for pages that has nothing to do with forms while making it much easier to deal with forms.
Comment #2
nedjoYep, that's the idea.
Comment #3
nedjoI've applied the patch. This means that all modules using tabs module will need to be updated.
Comment #4
zigma commentedtabs_render($form) in tabs.module breaks on php 5.0.5 and higher version. It could be just me. So you may want to validate it.
Breaking the call to render form in two statements makes it work.
//return drupal_render(form_builder('tabset', $form));
$built_form = form_builder('tabset', $form);
return drupal_render($built_form);
Comment #5
(not verified) commented