By amirn on
Hi,
I'm writing a module that displays editable tables, so I'm thinking of using Form API to create a form with all the fields I need and than use hook_theme to format the form as a table.
in the theme_myform() I can access all the fields I've defined and their values, and format them as a table, but I don't know how to add a collapsible div around the table (even if I add a #collapsible tag to the form, when I'm in the theme function I don't know of to use it.
some code from my module:
function theme_myform($form) {
$rows = array();
foreach (element_children($form['portfolio']) as $key) {
$row = array();
if (isset($form['portfolio'][$key]['name'])) {
$row[] = array('data' => drupal_render($form['portfolio'][$key]['name']));
$row[] = array('data' => drupal_render($form['portfolio'][$key]['category']));
$row[] = array('data' => drupal_render($form['portfolio'][$key]['createdon']));
$rows[] = $row;
}
}
//table headers.
$header = array();
$header[] = t('Name');
$header[] = t('Category');
$header[] = t('Created on');
$output = theme('table', $header, $rows);
$output .= drupal_render($form);
return $output;
The 'portfolio' is a fieldset in the $form that is defined as collapsible, but it gets ignored.
I'm using D6 but I don't mind using D7 if it's easier/better
Any help if welcome,
Thanks