You are here

function theme_conditional_fields_form_item in Conditional Fields 6

Same name and namespace in other branches
  1. 5 conditional_fields.module \theme_conditional_fields_form_item()
  2. 6.2 conditional_fields.module \theme_conditional_fields_form_item()

Themes the wrappers around conditional fields. Note that if you modify the id and classes of these fields, you have to modify conditional_fields.js accordingly.

File

./conditional_fields.module, line 1134
Content fields and groups visibility based on the values of user defined 'trigger' fields.

Code

function theme_conditional_fields_form_item($item) {
  if ($item['#required_field']) {
    $item = conditional_fields_set_required_field($item);
  }
  if ($id = $item['#controlling_field']) {
    return '<div id="conditional-' . conditional_fields_form_clean_id($id) . '" class="conditional-field controlling-field">' . drupal_render($item) . '</div>';
  }
  elseif ($id = $item['#controlled_field']) {
    if ($item['#type'] == 'markup') {

      /* Manage ahah multiple fields */
      if ($item['#conditional_fields_multiple']) {
        return '<div id="conditional-' . conditional_fields_form_clean_id($id) . '" class="conditional-field controlled-field">' . theme('content_multiple_values', $item) . '</div>';
      }

      /* Avoid unnecessary divs in other kinds of fields */
      $item['#prefix'] = '<div id="conditional-' . conditional_fields_form_clean_id($id) . '" class="conditional-field controlled-field">' . $item['#prefix'];
      $item['#suffix'] = $item['#suffix'] . '</div>';
      return drupal_render($item);
    }
    else {
      return '<div id="conditional-' . conditional_fields_form_clean_id($id) . '" class="conditional-field controlled-field">' . drupal_render($item) . '</div>';
    }
  }
  else {
    return drupal_render($item);
  }
}