There is a similar post somewhere on how to do radios in columns. The method I posted in a comment is much simpler than what that author suggests. It's really simple CSS.
Nancy E. Wichmann, PMP Injustice anywhere is a threat to justice everywhere. -- Dr. Martin L. King, Jr. -----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of David Metzler Sent: Wednesday, January 13, 2010 10:40 PM To: [email protected] Subject: Re: [development] Creating embedded unordered lists of checkboxes I think you're on the right track. Check out: http://drupal.org/node/197578 which shows you how to render a checkboxes control into a table. You shouldn't technically need the form-item theme function to do what you're doing, but rather just a custom checkboxes theming form. I've done that successfully in D5, but it looks like it would work in D6. Note the direct calls to theme_checkbox in that function so that it renders each of the checkboxes properly Hope that helps, Dave On Jan 13, 2010, at 4:54 PM, Steve Edwards wrote: > I have a need to create a two-level unordered list of checkboxes > from a two level taxonomy vocabulary. So for instance, if my > vocabulary is > > - Level 1 term 1 > -- Level 2 term 1 > -- Level 2 term 2 > -- Level 2 term 3 > - Level 1 term 2 > -- Level 2 term 4 > -- Level 2 term 5 > - Level 1 term 3 > > I want to create the following: > > <ul> > <li><input type = checkbox">Level 1 term 1</li> > <ul> > <li><input type = checkbox">.Level 2 term 1</li> > <li><input type = checkbox">Level 2 term 2</li> > <li><input type = checkbox">Level 2 term 3</li> > </ul> > <li><input type = checkbox">Level 1 term 2</li> > <ul> > <li><input type = checkbox">Level 2 term 4</li> > <li><input type = checkbox">Level 2 term 5</li> > <ul> > <li><input type = checkbox">Level 1 term 3<li> > </ul> > > What is the best way to do this? Just use a checkboxes element > type and create my own theme function for the form? Modify > something like theme_item_list? Or is there a better (and easier) > way that I'm missing? > > What I tried doing was to create a theme function for my checkboxes > element by setting the #theme property for the element to my custom > theme function (and registering the function in hook_theme). I > then just made a copy of theme_checkboxes() (and theme_form_element > since it's called from theme_form_checkboxes) and renamed to match > hook_theme and the #theme property. However, when doing that, none > of my checkboxes are rendered at all. On stepping through the > code, I found the problem in drupal_render starting at line 2868: > > if (!isset($elements['#children'])) { > $children = element_children($elements); > // Render all the children that use a theme function. > if (isset($elements['#theme']) && empty($elements > ['#theme_used'])) { > $elements['#theme_used'] = TRUE; > > $previous = array(); > foreach (array('#value', '#type', '#prefix', '#suffix') as > $key) { > $previous[$key] = isset($elements[$key]) ? $elements > [$key] : NULL; > } > // If we rendered a single element, then we will skip the > renderer. > if (empty($children)) { > $elements['#printed'] = TRUE; > } > else { > $elements['#value'] = ''; > } > $elements['#type'] = 'markup'; > > unset($elements['#prefix'], $elements['#suffix']); > $content = theme($elements['#theme'], $elements); > > foreach (array('#value', '#type', '#prefix', '#suffix') as > $key) { > $elements[$key] = isset($previous[$key]) ? $previous > [$key] : NULL; > } > } > // Render each of the children using drupal_render and > concatenate them. > if (!isset($content) || $content === '') { > foreach ($children as $key) { > $content .= drupal_render($elements[$key]); > } > } > } > > So basically, because I have #theme set for the checkboxes field, > it skips the rendering of the individual checkbox elements. To me, > it makes sense that I override the theme function for the > checkboxes type since that's the element type, but that doesn't > seem to be the case. So what do I need to do to be able to simply > theme my checkboxes element? > > Thanks. > > Steve > No virus found in this incoming message. Checked by AVG - www.avg.com Version: 9.0.725 / Virus Database: 270.14.133/2612 - Release Date: 01/13/10 02:35:00
