You are here

function _conditional_fields_admin in Conditional Fields 6

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

Administration form for conditional fields

1 string reference to '_conditional_fields_admin'
conditional_fields_menu in ./conditional_fields.module
Implementation of hook_menu().

File

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

Code

function _conditional_fields_admin($form, $type) {
  $form = array();
  $form['js_set'] = array(
    '#type' => 'fieldset',
    '#title' => t('User Interface options'),
    '#collapsible' => TRUE,
  );
  $form['js_set']['js'] = array(
    '#type' => 'radios',
    '#options' => array(
      C_FIELDS_JS_NO => t("Don't use javascript. Fields are only hidden on node view."),
      C_FIELDS_JS_HIDE => t('Hide untriggered fields.'),
      C_FIELDS_JS_DISABLE => t('Disable untriggered fields.'),
    ),
    '#title' => 'Javascript',
    '#description' => t('Choose the desired javascript behaviour in node editing forms.'),
    '#default_value' => variable_get('c_fields_js_' . $type, C_FIELDS_JS_HIDE),
  );
  $form['js_set']['anim'] = array(
    '#type' => 'fieldset',
    '#title' => t('Animation'),
    '#description' => t('These settings have effect only if you select the "Hide untriggered fields" option above.'),
  );
  $form['js_set']['anim']['animation'] = array(
    '#type' => 'radios',
    '#title' => t('Type'),
    '#default_value' => variable_get('c_fields_animation_' . $type, C_FIELDS_ANIMATION_NO),
    '#options' => array(
      C_FIELDS_ANIMATION_NO => t('No animation'),
      C_FIELDS_ANIMATION_FADE => t('Slide down'),
      C_FIELDS_ANIMATION_SLIDE => t('Fade'),
    ),
  );
  $form['js_set']['anim']['anim_speed'] = array(
    '#type' => 'radios',
    '#title' => t('Speed'),
    '#description' => t('The speed at which the animation is performed. Slow = 600ms; Normal = 400ms; Fast = 200ms.'),
    '#default_value' => variable_get('c_fields_anim_speed_' . $type, 'normal'),
    '#options' => array(
      'slow' => t('Slow'),
      'normal' => t('Normal'),
      'fast' => t('Fast'),
    ),
  );
  $form['orphaned'] = array(
    '#type' => 'fieldset',
    '#title' => t('Orphaned controlled fields settings'),
    '#description' => t('Configure the visibility/editability of controlled fields whose controlling fields are not visible/editable.'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
  );
  $options = array(
    C_FIELDS_ORPHANED_HIDE => t('Hide'),
    C_FIELDS_ORPHANED_SHOW_TRIGGERED => t('Show only if triggered'),
    C_FIELDS_ORPHANED_SHOW_ALL => t('Show'),
  );
  $form['orphaned']['orphaned_view'] = array(
    '#type' => 'radios',
    '#title' => t('On node view'),
    '#options' => $options,
    '#default_value' => variable_get('c_fields_view_' . $type, C_FIELDS_ORPHANED_SHOW_TRIGGERED),
  );
  $form['orphaned']['orphaned_edit'] = array(
    '#type' => 'radios',
    '#title' => t('On node edit'),
    '#options' => $options,
    '#default_value' => variable_get('c_fields_edit_' . $type, C_FIELDS_ORPHANED_SHOW_TRIGGERED),
  );
  $form['reset_default'] = array(
    '#type' => 'checkbox',
    '#title' => t('Reset untriggered fields to default values'),
    '#description' => t('Select this box to reset untriggered controlled fields to their default values when saving a node.'),
    '#default_value' => variable_get('c_fields_reset_default_' . $type, 1),
  );
  $form['show_all'] = array(
    '#type' => 'checkbox',
    '#title' => t('Administrators see all fields'),
    '#description' => t('Select this box to let users with the <a href="@access-control-page">administer conditional fields</a> permission to view all controlled fields of a node.', array(
      '@access-control-page' => url('admin/user/permissions', array(
        'fragment' => 'module-conditional_fields',
      )),
    )),
    '#default_value' => variable_get('c_fields_show_all_' . $type, 0),
  );
  $form['delete'] = array(
    '#type' => 'checkbox',
    '#title' => t('Delete'),
    '#description' => t('Delete all conditional fields configured for this content type. This will delete the conditional fields settings, not the fields themselves.'),
    '#default_value' => 0,
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save'),
  );
  return $form;
}