You are here

function conditional_fields_field_overview_form in Conditional Fields 5

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

Find conditional fields, mark them, and disable groups select for them.

1 call to conditional_fields_field_overview_form()
conditional_fields_form_alter in ./conditional_fields.module
Implementation of hook_form_alter()

File

./conditional_fields.module, line 682

Code

function conditional_fields_field_overview_form(&$form) {

  // Check for valid content type
  if (!($type = content_types(arg(3)))) {
    return;
  }

  // Check if we have conditional data
  if (!($data = conditional_fields_load_data($type['type'], 'flat'))) {
    return;
  }

  // Disallow changing group of conditional fields
  foreach ($form['field-groups'] as $field_name => $field_settings) {
    if ($data[$field_name]) {
      $form['field-groups'][$field_name]['#disabled'] = 'disabled';
      $form['field-groups'][$field_name]['#description'] .= theme('conditional_field_conditional', 'conditional field');
    }
  }

  // Mark conditional groups
  foreach ($form['#table'] as $key1 => $field) {
    foreach ($field as $key2 => $group) {
      foreach ($group as $group_name => $group_settings) {
        if ($group_settings['type'] == 'group' && $data[$group_name]) {
          $form['#table'][$key1][$key2][$group_name]['groups'] = theme('conditional_field_conditional', 'conditional group');
        }
      }
    }
  }
}