I need to add some html to specific radio buttons. This is a picture to clarify what I'm looking for:

enter image description here

As you can see I want to add some text to the options. These are radio buttons where you can select one option. This is what I have now:

enter image description here

I've tried adding html with the theme_radio function with suffix like this:

function ppprogram_radio($variables) {
    $element = $variables['element'];
    $element['#attributes']['type'] = 'radio';
    $element['#suffx'] = "<p>just testing</p>";

    element_set_attributes($element, array('id', 'name','#return_value' => 'value'));

    if (isset($element['#return_value']) && $element['#value'] !== FALSE && $element['#value'] == $element['#return_value']) {
        $element['#attributes']['checked'] = 'checked';
    _form_set_class($element, array('form-radio'));

    return '<input' . drupal_attributes($element['#attributes']) . ' />';

But that didn't do anything ... . I've also tried adding html to the return but then it's added before my label and I want it after my label.

3 Answers 3


Hope this will help. please follow the comments.

 function CUSTOMMODULENAME_form_alter(&$form, &$form_state, $form_id){
        if($form_id=='YOUR FORM ID'){
           /* uncomment the following code after updating the key variables<field machine name> and check out the option keys.
           // echo '<pre>';
           // print_r($form['<field machine name>']['und']['#options']);
            $form['<field machine name>']['und']['#options']['<key>'] .= '<h3>Hello World </h3>'; 
            // the above code will add <h3>Hello World </h3> alone with the existing radio button label
//Remove the comments if it helps.


Let me know if you need any additional clarity.


  • Thanks! It works, what would be the best solution. This one or the previous answer of wolverine?
    – nielsv
    Jul 3, 2014 at 15:25

'suffx' is misspelled on line 4. Does it work if you correct the spelling?

 $element['#suffix'] = "<p>just testing</p>";
  • no, still nothing ..
    – nielsv
    Jul 3, 2014 at 8:18

Implement theme_form_element_label($variables) in your template.php and append your value to the returning label.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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