By tkilbour on
I have a problem in a multi-part form I'm building as part of the admin page for a module I'm developing.
I pull an array from a DB table, but I can't render the form radio buttons using the array. Everything displays right, I get no errors, but no radios appear (the title and description display fine) and I know the array is populated by the message.
code:
$listo = array();
$result = db_query('SELECT * FROM {gallerease} n WHERE n.master = 1');
while ($list = db_fetch_object($result)) {
array_push($listo, $list->tags);
}
$listn = array_unique($listo);
$form['taglist'] = array(
'#type' => 'radios',
'#title' => t('Image galleries'),
'#options' => $listn,
'#description' => t('Select a tag to edit associated images'),
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Submit')
);
drupal_set_message(count($listn) . $listn[0]);
$output = '';
$output .= drupal_render($form['taglist']);
$output .= drupal_render($form['submit']);
return $output;
Comments
What happens when you
What happens when you populate your options manually? Do any radios appear?
Replace '#options' => $listn,
With
'#options' => array( t('option 1'), t('option 2'), t('option 3') ),
To debug
Hmm, manual options don't
Hmm, manual options don't work either. When I change the form type to 'select' they show up fine, but I get this error: warning: implode() [function.implode]: Invalid arguments passed in /home/****************/public_html/includes/form.inc on line 623. Then the rest of the form becomes unusable, obviously. I wonder if it's the same problem, but drupal isn't catching an error message for the radios?
However! If I change the form handling around so that the menu item callback is drupal_get_form(), with the form function as a callback argument, then return $form in the form function everything works fine. But I really don't want to do it that way because I need to display a bunch of other stuff on the page besides just a form.
Here is all the code I'm using: