You are here

function theme_conditional_fields_form_item in Conditional Fields 5

Same name and namespace in other branches
  1. 6.2 conditional_fields.module \theme_conditional_fields_form_item()
  2. 6 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 895

Code

function theme_conditional_fields_form_item($item) {
  if ($id = $item['#controlling_field']) {
    $output = '<div id="conditional-' . form_clean_id($id) . '" class="conditional-field controlling-field">' . drupal_render($item) . '</div>';
  }
  else {
    if ($id = $item['#controlled_field']) {
      conditional_fields_set_required_for_render(&$item);
      if ($item['#type'] == 'markup') {

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