I'm trying to theme some form elements individually by adding the #theme attribute to the element I want to theme. This works fine for textareas, selects, etc... but when theming radios or checkboxes it is the children (i.e. the options) that use the defined theme function, and not the element itself. The element itself is passed through the default theme_radios/theme_checkboxes.

I would like to be able to theme the element's title to add markup around it, however I can't do this with radios or checkboxes as the title is overridden by the default theme function, regardless of what's specified. Was this intentional?

Is there a way for me to achieve what I want using any of the #process, #after_build, etc... callbacks? Or do I have to put the #theme on the parent element and handle the theming of all the children/options myself?

CommentFileSizeAuthor
#7 D6-form.inc_.patch1.37 KByonailo

Comments

ainigma32’s picture

Good question ;-)

Unfortunately I don't have the answer. Maybe you could just try some experiments and see what you can come up with?
I'm sure there are more, less skilled drupalistas looking for this info.

- Arie

damien tournoud’s picture

Status: Active » Postponed (maintainer needs more info)

I don't see that behavior anywhere in the code: a #theme function applied to a "checkboxes" element should override theme_checkboxes().

Could you pastebin some code isolating the broken behavior you are seeing?

cdale’s picture

Status: Postponed (maintainer needs more info) » Closed (fixed)

I can't seem to reproduce this problem anymore, so I'll close this issue. If I manage to make it happen again, I'll reopen with more information.

chewie’s picture

Version: 7.x-dev » 6.16
Component: base system » forms system

I confirm this problem at drupal 6-xx current version
when use theme_radios or drupal_render() #options didn't work
I dont found any remarks at api.drupal.org about radios rendering or theming

yonailo’s picture

Status: Needs review » Closed (fixed)

For example:

....
  $form['radio_test'] = array(
    '#type' => 'radios',
    '#title' => 'test',
    '#options' => array( 'a', 'b', 'c' ),
  );

  echo drupal_render($form['radio_test']);

This code does not show the radio options. Is this the expected behavior (tested avec latest D6 version) ?

yonailo’s picture

Status: Closed (fixed) » Needs review
yonailo’s picture

Status: Closed (fixed) » Needs review
StatusFileSize
new1.37 KB

Status: Needs review » Needs work

The last submitted patch, D6-form.inc_.patch, failed testing.

Status: Needs work » Closed (outdated)

Automatically closed because Drupal 6 is no longer supported. If the issue verifiably applies to later versions, please reopen with details and update the version.