You are here

function conditional_fields_content_admin_field_controlling in Conditional Fields 6.2

Same name and namespace in other branches
  1. 6 conditional_fields.module \conditional_fields_content_admin_field_controlling()

Controlling field settings form (just a table containing information about controlled fields)

1 call to conditional_fields_content_admin_field_controlling()
conditional_fields_content_admin_field in ./conditional_fields.module
Alteration of the field editing form

File

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

Code

function conditional_fields_content_admin_field_controlling($type, $controlled_fields) {
  foreach ($controlled_fields as $field => $trigger_values) {
    if (strpos($field, 'group_') === 0) {

      // It's a group
      $rows[] = array(
        $field,
        implode($trigger_values, ', ') . ' (' . t('<a href="@edit-group">edit</a>', array(
          '@edit-group' => url('admin/content/node-type/' . $type['url_str'] . '/groups/' . $field, array(
            'fragment' => 'conditional-fields-settings',
          )),
        )) . ')',
        t('group'),
      );
    }
    else {

      // It's a field
      $rows[] = array(
        $field,
        implode($trigger_values, ', ') . ' (' . t('<a href="@edit-field">edit</a>', array(
          '@edit-field' => url('admin/content/node-type/' . $type['url_str'] . '/fields/' . $field, array(
            'fragment' => 'conditional-fields-settings',
          )),
        )) . ')',
        t('field'),
      );
    }
  }
  $output = array(
    '#type' => 'fieldset',
    '#title' => t('Controlled fields') . ' (' . count($rows) . ')',
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
    '#description' => '<p>' . t('Below are listed all fields and groups controlled by this field.') . '</p>',
    'controlled_fields_table' => array(
      '#value' => theme('table', array(
        t('Name'),
        t('Trigger values'),
        t('Type'),
      ), $rows),
    ),
  );
  return $output;
}