GRRRRRRR,
Ok, the new form API is cool and all, But im really having a pain displaying and editing this stuff.
Here it goes....
$form['easiness'] = array(
'#type' => 'radios',
'#title' => t('Easiness 1-5'),
'#options' => array('','','','',''),
'#required' => TRUE,
);
That outputs 5 radio buttons one on top of the other (vertically). I need them all to be horizontal. Then, the first radio button has a value of "0", the next "1", etc. I need the radio buttons to start from 1 and go to 5.
Also, when i do...
$output = drupal_get_form('test_page', $form);
return $output;
That prints all the things in the $form array...BUT... how come it shows them with
tags? How can I make it so its just the line and nothing else.
Please help, im lost!
Comments
options array
You need to properly define your options array.
I'm confused though. Do you mean something like this:
array('0' => '1', '1' => '2', '2' => '3', '3' => '4', '4' => '5');
where '0' is the value and '1' is the label and so on. Season to taste.
The form API will loop through and output the radio buttons accordingly.
I believe there is a method for controlling the output format. Check drupaldocs.org.
well
ok, so i used array('1' => '', '2' => '', '3' => '', '4' => '', '5' => ''),
cause i didnt need the labels.
But i cant find how to make them horizontal in drupaldocs.org thats why i posted here. Thanks for the help bacteria man
try theme_radios
I think theme_radios is what you're looking for.
Couldn't figure it out either
Hey Chupcha,
Yeah - even with the theming functions, I'm not sure there's a way to do this either. The hack I found was to just manually create the radio buttons using regular markup, kinda like this:
This made a radio button that I could access in the next step through:
I'm already using Drupal 5.1... are there any plans to add this functionality to a future version of the Form API?
You can add the following
You can add the following properties:
'#prefix' => '
'#suffix' => '
',
So your element definition will be:
$form['easiness'] = array(
'#type' => 'radios',
'#title' => t('Easiness 1-5'),
'#options' => array('','','','',''),
'#required' => TRUE,
'#prefix' => '
'#suffix' => '
',
);
Due to CSS definition of class "container-inline" your radios will be rendered horizontally.
Hope this helps
Even i am facing same issue
Hi guys..
even i am facing the same issue.i want to display my radio buttons in same line.
unable to get how..
:(
it can be done.
Hi guys..
I recently came to know that we can give prefix with '#prefix' => '
', and you get radio buttons in a line, not vertically aligned.For me it worked.
so the code for radio button looks like: