0

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

  • Use tags to indicate drupal version. And when refering to form elements, use their formal type in unambigious way. '#type' => 'radios', right? Not just many single '#type'=>'radio'? – Mołot May 24 '13 at 13:50
1

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.

0

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. – rashidkhan May 24 '13 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. – Ankur140290 May 24 '13 at 13:50
  • No, drupal does not give IDs to each radio inside #type=>radios, that's why I asked it. – rashidkhan May 24 '13 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łot May 24 '13 at 14:05
  • 1
    @Ankur Can you expand a little on how the OP can use jQuery to do this? – mpdonadio May 24 '13 at 15:13
0

The Display Suite module might be what you're looking for:

http://drupal.org/project/ds

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for?Browse other questions tagged or ask your own question.