You are here

function conditional_fields_content_admin_field_controlling in Conditional Fields 6

Same name and namespace in other branches
  1. 6.2 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 388
Content fields and groups visibility based on the values of user defined 'trigger' fields.

Code

function conditional_fields_content_admin_field_controlling(&$form, $type, $controlled_fields) {
  $description = '<p>' . t('Below is a list of all fields and groups controlled by this field. If you want to make this field controllable, you have to clear the settings for each controlled field.') . '</p>';
  conditional_fields_content_admin_field_fieldset($form, $description);
  foreach ($controlled_fields as $field => $trigger_values) {
    if (strpos($field, 'group_') === 0) {

      // It's a group
      $rows[] = array(
        $field,
        implode($trigger_values, ', '),
        t('group'),
        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',
          )),
        )),
      );
    }
    else {

      // It's a field
      $rows[] = array(
        $field,
        implode($trigger_values, ', '),
        t('field'),
        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',
          )),
        )),
      );
    }
  }
  $form['conditional_fields']['controlled_fields'] = array(
    '#value' => theme('table', array(
      t('Name'),
      t('Trigger values'),
      t('Type'),
      t('Options'),
    ), $rows),
  );
}