I am using drupal form radios, I can use Prefix and Suffix to assign IDs to group, how can I assign different IDs to each radio button inside the radios element? Thanks
3 Answers
You need to use theme_radios() hook in your template.php file, if what you get is insufficient.
Parameters
$variables: An associative array containing:
- element: An associative array containing the properties of the element. Properties used: #title, #value, #options, #description, #required, #attributes, #children.
Return value
A themed HTML string representing the radio button set.
To interfere with single radio element, see theme_radio(), of course.
You can use jQuery for giving extra IDs for your radio buttons.
-
Is it not possible through drupal? I want to implement the drupal way. May 24, 2013 at 13:46
-
I think Drupal itself gives IDs to all the radio buttons you have on the page. You only need to inspect it properly. May 24, 2013 at 13:50
-
No, drupal does not give IDs to each radio inside #type=>radios, that's why I asked it. May 24, 2013 at 14:01
-
@Ankur - "Drupal" does not give IDs. Theme can give them. Or not. If rashidkhan can't see them, it's well possible theme he is using does not add them.– MołotMay 24, 2013 at 14:05
-
1@Ankur Can you expand a little on how the OP can use jQuery to do this?– mpdonadio ♦May 24, 2013 at 15:13
The Display Suite module might be what you're looking for:
Display Suite lets you create your own id's and classes, and then assign them to your form fields, either keeping Drupal's default and adding your new ones, or it can completely replace the existing id's and classes with your new ones. Here's a screen shot of a radio button field I have on a form I recently created: http://www.territorialnetworks.com/design-suite.png
Design Suite also lets you control the layout of your form with different column configurations and orientations.