I have a field named field_event_type. When creating a node, you can select one of two options for this field from a drop-down list:
- birthday party
- Wedding
I want to be able to display different fields in my node depending on which type of event is selected. So in node--events.tpl.php, my node template, I wrote the following:
if ($element['#object']->field_event_type['und'][0]['value'] == 'birthday party' )
{
print render($content['field_some_field']);
}
else
{
print render($content['field_some_other_field']);
}
However, this does not seem to be working the way I intended it to, not only is it not displaying the additional field content in either event type, but I'm also getting an error in Drupal about an undefined variable. Is my code incorrect?