Posted by RodrigoBalest on February 27, 2013 at 9:19pm
Hi.
I'm trying to theme a fieldset generated by the module Field Group (http://drupal.org/project/field_group).
I'm implementing the following hook_fieldset in my theme:
function MYTHEME_fieldset($variables) {
$element = $variables['element'];
element_set_attributes($element, array('id'));
_form_set_class($element, array('form-wrapper'));
$output = '<fieldset' . drupal_attributes($element['#attributes']) . '>';
if (!empty($element['#title'])) {
// Always wrap fieldset legends in a SPAN for CSS positioning.
$output .= '<legend><span class="fieldset-legend">' . $element['#title'] . '</span></legend>';
}
$output .= '<div class="fieldset-wrapper">';
if (!empty($element['#description'])) {
$output .= '<div class="fieldset-description">' . $element['#description'] . '</div>';
}
if(function_exists('render_' . $element['#id']))
{
var_dump('render_' . $element['#id']);
$output .= call_user_func('render_' . $element['#id'], array($element));
}
else
{
$output .= $element['#children'];
}
if (isset($element['#value'])) {
$output .= $element['#value'];
}
$output .= '</div>';
$output .= "</fieldset>\n";
return $output;
}And the function that (tries to) render de fieldset contents:
function render_node_vehicle_form_group_precos_radio($element)
{
//var_dump($element[0]['field_radio_deftime_15']);
$table = '<table>';
$table .= '<thead><tr><td></td><th scope="col">15″</th><th scope="col">30″</th></tr><thead>';
$table .= '<tbody>';
$table .= '<tr><th scope="row">Defined time</th><td>' . drupal_render($element[0]['field_radio_deftime_15']) . '</td><td>' . drupal_render($element[0]['field_radio_deftime_30']) . '</td></tr>';
$table .= '<tr><th scope="row">Undefined time</th><td>' . drupal_render($element[0]['field_radio_undeftime_15']) . '</td><td>' . drupal_render($element[0]['field_radio_undeftime_30']) . '</td></tr>';
$table .= '</tbody>';
$table .= '</table>';
return $table;
}As you can see, I tryed var_dump the field, and found out that it's ['#printed'] key is 'true', and it makes drupal_render returns nothing.
So, what's the right way of achieve this?
Thanks!
Comments
Solved. That's what I did:
In the example above, just changed (eg.)
drupal_render($element[0]['field_radio_undeftime_15'])with
$element[0]['field_radio_undeftime_15']['#children']Thanks.