1

Is it possible to set the markup (#prefix and #suffix) around individual radio buttons? I know that I can add these fields to the radio button group, but that would mean that I would be wrapping the entire group, which is not what I want to do.

2

According to the Forms API matrix you can. See https://api.drupal.org/api/drupal/developer!topics!forms_api_reference.html/7#radio Have you tried some code to see if it does what you are looking for?

You can set '#options' for the radios to be a variable:

$rads = array( 
  0 => '<span>' . t('Yes') . '</span>', 
  1 => '<span>' . t('No') . '</span>', );

$form['fldset8']['exp_radios'] = array(
 '#type' => 'radios', 
 '#options' => $rads, );
  • Yeah, I saw that. But I don't really know how to test it. Where would I put the tag? I have my options listed as '#options'=> array(1,2,3) -- so, where would I put a #prefix element? – user1015214 Nov 4 '13 at 20:33
  • You can set '#options' for the radios to be a variable: $rads = array( 0 => '<span>' . t('Yes') . '</span>', 1 => '<span>' . t('No') . '</span>', ); $form['fldset8']['exp_radios'] = array( '#type' => 'radios', '#options' => $rads, ); – StevenPatz Nov 4 '13 at 20:49

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.