Hi All,
I am having the following problem. I have coded my module so that it generates 5 columns with 4 rows of check boxes for input. The FAPI part looks as follows :
$name_arr = array(
"1",
"2",
"3",
"4",
"5",
"6",
"7",
"8",
"9",
"10",
"11",
"12",
"13",
"14",
"15",
"16",
"17");
$form['image_sizes'] = array(
'#type' => 'fieldset',
'#title' => t('Activities on Site or in Area'),
'#tree' => TRUE,
'#theme' => 'activities_on_site_or_in_area_form',
);
$counter = 0;
$row_amount = (count($name_arr)/5);
while ( $counter < count($name_arr) )
{
$form['image_sizes'][$name_arr[$counter]] = array(
'#type' => 'checkbox',
'#title' => t($full_name_arr[$counter]),
);
$counter++;
}
Ok... this generates all the fields fine. Maybe not use a while loop now that I think about it but the above works fine. As stated in my first sentence I want to have this in 5 columns of 4 rows. I have therefore created the below theme function :
function theme_activities_on_site_or_in_area_form(&$form) {
//$header = array(t('Label'), t('Operation'), t('Width'), t('Height'), t('Link'));
$cols = 5;
$name_arr = array(
"1",
"2",
"3",
"4",
"5",
"6",
"7",
"8",
"9",
"10",
"11",
"12",
"13",
"14",
"15",
"16",
"17");
for ($i = 0; $i < ceil(count($form['image_sizes'])/$cols); $i++)
{
$row = array();
for ($j = ($i*$cols); $j < (($i*$cols) + $cols); $j++)
{
$row[] = drupal_render($form['image_sizes'][$name_arr[$j]]);
}
$rows[] = $row;
}
$output = theme('table', '', $rows);
$output .= drupal_render($form);
return $output;
}
Now according to all the entries found in search on this forum it should work. Example being Example if I call the theme function explicitly it renders the table at the top of the site which is not really an issue as it's just to test. Seems as if the theme function is never called.
Also should the parameter that is passed to the theme_ function be &$form or just $form?
Anyone know what I am doing wrong here?
Thanks in advance.
Davin.
Comments
You haven't mentioned whether or not your
theme function is registered in your modules hook_theme(). This is a new requirement in Drupal 6.
--
Anton
How do I do that?
Hi,
I havn't done anything like that. Is there a document that I can see how it looks?
Thanks in advance.
Davin.
Changes I have made.
Hi,
I have now checked it out and I have created the following function:
This now just gives me the headings which is better than before atleast. Still doesn't give me the rows. What am I still missing?
Thanks in advance.
Davin.
Not sure
but now that you are getting the table headings, that means that your theme function is registered and running and that theme_table() is at least outputting something.
So I suspect there is a problem in how you are creating the rows for theme_table(). I'd double check your rows array - maybe even test it by just using some statically defined rows to check whether you have the array structure right etc.
--
Anton