Dependent fields don't seem to work when used in tables

crooke - September 2, 2008 - 16:47
Project:Dependent Fields
Version:5.x-1.4-beta
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:active
Description

Hi!

Great module, thanks!

I have a little problem with it. Everything was working fine and I was really happy with the module. But I had to override my template.php to render the forms into table cells. Here's the code I use:

function mythemename_form_element($element, $value) {
  $output  = '<table id="form-table"><tr><div class="form-item '. $element['#id']. '">';
  $required = !empty($element['#required']) ? '<span class="form-required" title="'. t('This field is required.') .'">*</span>' : '';

  if (!empty($element['#title'])) {
    $title = $element['#title'];
    if (!empty($element['#id'])) {
      $output .= '<td> <label for="'. $element['#id'] .'">'. t('!title: !required', array('!title' => filter_xss_admin($title), '!required' => $required)) ."</label></td>\n";
    }
    else {
      $output .= ' <label>'. t('!title: !required', array('!title' => filter_xss_admin($title), '!required' => $required)) ."</label>\n";
    }
  }

  $output .= "<td> $value</td>\n";

  if (!empty($element['#description'])) {
    $output .= ' <div class="description">'. $element['#description'] ."</div>\n";
  }

  $output .= "</tr></table>\n";

  return $output;
}

As you can see this is a really basic theme override. Now since I applied this modification my dependent fields don't seem to work. This is probably a design issue I guess, but can you please let me know what I should do? I really need the dependent fields but I need my forms rendered into <tr> ... </tr> so labels are on the left, input fields are on the right so it all looks like a well formed form.

Any advice would be really great!

Thanks

 
 

Drupal is a registered trademark of Dries Buytaert.