Hi,

I want to divide my radiobuttons into 2 fieldsets

in HTML it would like this:

<fieldset>
<input type="radio" name="test"... value="1">..
</fieldset>
<fieldset>
<input type="radio" name="test"... value="2">..
</fieldset>

I do not know, how to achieve this in drupal. I think somehow I should use #tree, but the use of it resulted in this

<fieldset>
<input type="radio" name="test[part1]"... value="1">..
</fieldset>
<fieldset>
<input type="radio" name="test[part2]"... value="2">..
</fieldset>

Is there a suggested drupal-way?

Thanks in advance.

Markus

Comments

Island Usurper’s picture

Actually, #tree would be used to distinguish the two sets of radio buttons from each other even though they have the same name. Try setting #tree to false with that array structure. If that doesn't work, maybe you can manually set the name with

  '#attributes' => array('name' => 'test'),

-----
Übercart -- One cart to rule them all.

NewToDruballer’s picture

Hi,

thanks for your fast reply.

Sorry, I did not track down my efforts to the end:

I can create the above code by using eg:

$form['fields']['test1']=array(
     '#type'=>'fieldset'
     '#title'=>test1
     '#options'=>array('1'=>1,'2'=>2));
$form['fields']['test2']=array(
     '#type'=>'fieldset'
     '#title'=>test2
     '#options'=>array('3'=>3,'4'=>4));

This results in the above code.

But after submitting the form, I get the message "An illegal choice has been detected. Please contact the site administrator." called in form.inc:563
If I understand the code right, each element is called seperately and checks (in case of an radio-/checkbox) if the value selected by the user is allowed - what means that it is a value of a radiobutton in the actual element. But if I divide it in two parts, the selected value will not be in one array.

So it seems, this is my problem. Any ideas?

Markus

NewToDruballer’s picture

Ok,

I now added ['#DANGEROUS_SKIP_CHECK']=true to the elements. I think I can handle a numeric check myself :-)

Thanks for your help and my solution :-D

Markus