[EDIT: don't bother to read this - it was a wild goose chase, and the very obvious solution is in the first reply, below]
I have a large form with over a hundred elements, about 70 of which are yes/no radios in columns. I want to hide the labels on these radios since they're redundant, but I don't want to hide the labels on other radios on the form. In other words, I need to somehow apply conditional theming to my radio labels.
I'd really like to do this the right way, but am stymied.
Things that either don't solve the problem, or don't solve it very elegantly:
* Label display:none in css. No go, as the label element wraps (and thus hides) the input element.
* Override theme_radio(). Because CCK expands my '#type' => 'radios' element into two '#type' => 'radio' children, by the time hook_radio gets called I can't figure out any way to tell which element I'm dealing with, other than hardcoding in the names, which I would rather not do.
* Override theme_radios(). Requires, AFAICT, ugly hacking. First, I have to add a non-standard key to the element array in the form definition, so that I can recognize it at the proper time (as in code below). Worse, I have to modify the already rendered HTML output with regex string replacements.
Non-standard use of form api:
$form['Heart_Disease'] = array(
'#type' => "radios",
'#options' => array('1' => t('Yes'), '0' => t('No')),
'#title' => '1. Heart disease of any kind',
'#my_theming_flag' => 'no-label', // custom processing flag; is this even ok per drup stds?
);
* Specify '#type' => 'radios' elements' theme functions with '#theme' => 'my_custom_renderer'. First, I can't get it to work. No matter what I use for the value of '#theme' and no matter how many times I clear the theme registry, drupal ignores me. I'm assuming '#theme' only works with registered hooks, and I really don't want to have to make module-level changes to accomplish this properly theme-level task. Second, even if I did make it work, it would only affect the parent 'radios' element, not the child 'radio' elements.
I'm sure there's some super easy way to conditionally theme these radio elements, perhaps by intercepting cck's pre-render expansion of the element, but I could sure use a pointer or two.
Thanks!
Comments
Or...
Or...
An intelligent person could just do this:
But that's so much less fun than playing with hooks and callbacks...
Ug.
:)