Hi,

I need to render a form with radio buttons, each option in is own table row.

I already know that I need #parents and #tree, but I don’t get it :-(

How can I accomplish this? All I get is all the options (radio buttons) in the same row.

Thanks,
introfini

Comments

captaindrunk’s picture

#prefix and #suffix options should allow you to do this when creating the form should allow this

'#prefix' => '<td>',
'#suffix' => '</td>',

All depends how you are generating your radios

introfini’s picture

Thanks, but it was more complicated than that.

I solved it with something like this:

 foreach (element_children($form['temas']['#options']) as $key) {  
  $row[] = array(form_render($form['temas'][$key]),'aaaa');
 }

Thanks,
introfini
josefernandes.pt

José Fernandes
Bloomidea

geek.de.nz’s picture

I'm developing a feemanager module so my club can manage their fees. I chose to write a generic module, so that others can benifit from it. I need a form for which only one row can be selected. I would prefer to render this in a table.

So how would I do this for radio buttons where only one can be selected as with this option?

<code>
	$form['fee_types']['default'] = array(
		'#type' => 'radios',
		'#title' => 'Default fee type',
		'#prefix' => '<table>',
		'#options' => array(
			'<tr><td>'.t('test 1').'</td><td><a href="link">edit</a></td></tr>',
			'<tr><td>'.t('test 2').'</td><td><a href="link">edit</a></td></tr>',
			'<tr><td>'.t('test 3').'</td><td><a href="link">edit</a></td></tr>'
		),
		'#suffix' => '</table>',
		'#description' => t('Select the default fee type with the left radio button.'),
	);


does not work. Help! Help! I need to finish this project by friday. Doing it without a table for now, but would be good for my presentation (with tables).

http://www.ihostnz.com

introfini’s picture

Look at the code in system.module and how you can choose the available templates.

introfini
josefernandes.pt

José Fernandes
Bloomidea