I have a table inside a form. I'm trying to display a 'select' form element in one of the table columns, but it doesn't display; it keeps getting rendered outside of the table. However, if I change the form element to 'checkboxes' or 'radios', it displays without problem.
I'm rendering like this: $output .=开发者_运维问答 theme('table', $header, $rows);
where $header
is an array for the table headings and $rows
is an array of array (the table rows).
The rows array is built like this:
$row[] = drupal_render($form['fname'][$key]);
$row[] = drupal_render($form['lname'][$key]);
$row[] = drupal_render($form['days'][$key]);
$rows[] = $row;
What I want is for the final row ('days') to be a select box instead of a checkbox, but when I change it to select, its being displayed outside the table.
Any ideas?
This is my theme function:
function theme_client_admin_nodes($form) {
$has_posts = isset($form['fname']) && is_array($form['fname']);
$header = array(t('First Name'), t('Last Name'), t('Packages'), t('Day'));
$output = '';
if ($has_posts) {
foreach (element_children($form['fname']) as $key) {
$row = array();
$row[] = drupal_render($form['fname'][$key]);
$row[] = drupal_render($form['lname'][$key]);
$row[] = drupal_render($form['packages'][$key]);
$row[] = drupal_render($form['days'][$key]);
// $row[] = drupal_render($form['nodes'][$key]);
$rows[] = $row;
}
}
else {
$rows[] = array(array('data' => t('No posts available...'), 'colspan' => '4'));
}
$output .= theme('table', $header, $rows);
if ($form['pager']['#value']) {
$output .= drupal_render($form['pager']);
}
$output .= drupal_render($form);
return $output;
}
Have a look at http://drupal.org/project/elements. It should do what you are looking for.
精彩评论