You are here

function fieldgroup_edit_group_form in Content Construction Kit (CCK) 6

Same name and namespace in other branches
  1. 5 fieldgroup.module \fieldgroup_edit_group_form()
4 string references to 'fieldgroup_edit_group_form'
content_copy_export in modules/content_copy/content_copy.module
Process the export, get field admin forms for all requested fields and save the form values as formatted text.
content_copy_form_alter in modules/content_copy/content_copy.module
Implementation of hook_form_alter(). Intervene to run form through macro when doing export
content_copy_record_macro in modules/content_copy/content_copy.module
A handler that stores the form submissions into a $GLOBALS array
fieldgroup_menu in modules/fieldgroup/fieldgroup.module
Implementation of hook_menu().

File

modules/fieldgroup/fieldgroup.module, line 90
Create field groups for CCK fields.

Code

function fieldgroup_edit_group_form(&$form_state, $content_type, $group_name, $action) {
  $groups = fieldgroup_groups($content_type['type']);
  if ($action == 'add') {

    //adding a new one
    $group = array();
    $form['submit'] = array(
      '#type' => 'submit',
      '#value' => t('Add'),
      '#weight' => 10,
    );
  }
  elseif ($group = $groups[$group_name]) {
    $form['submit'] = array(
      '#type' => 'submit',
      '#value' => t('Save'),
      '#weight' => 10,
    );
  }
  else {
    drupal_not_found();
    exit;
  }
  $form['label'] = array(
    '#type' => 'textfield',
    '#title' => t('Label'),
    '#default_value' => isset($group['label']) ? $group['label'] : '',
    '#required' => TRUE,
  );
  $form['settings']['#tree'] = TRUE;
  $form['settings']['form'] = array(
    '#type' => 'fieldset',
    '#title' => 'Form settings',
    '#description' => t('These settings apply to the group in the node editing form.'),
  );
  $form['settings']['form']['style'] = array(
    '#type' => 'radios',
    '#title' => t('Style'),
    '#default_value' => isset($group['settings']['form']['style']) ? $group['settings']['form']['style'] : 'fieldset',
    '#options' => array(
      'fieldset' => t('always open'),
      'fieldset_collapsible' => t('collapsible'),
      'fieldset_collapsed' => t('collapsed'),
    ),
  );
  $form['settings']['form']['description'] = array(
    '#type' => 'textarea',
    '#title' => t('Help text'),
    '#default_value' => isset($group['settings']['form']['description']) ? $group['settings']['form']['description'] : '',
    '#rows' => 5,
    '#description' => t('Instructions to present to the user on the editing form.'),
    '#required' => FALSE,
  );
  $form['settings']['display'] = array(
    '#type' => 'fieldset',
    '#title' => 'Display settings',
    '#description' => t('These settings apply to the group on node display.'),
  );
  $form['settings']['display']['description'] = array(
    '#type' => 'textarea',
    '#title' => t('Description'),
    '#default_value' => isset($group['settings']['display']['description']) ? $group['settings']['display']['description'] : '',
    '#rows' => 5,
    '#description' => t('A description of the group.'),
    '#required' => FALSE,
  );
  module_load_include('inc', 'content', 'includes/content.admin');
  foreach (array_merge(array_keys(_content_admin_display_contexts(CONTENT_CONTEXTS_SIMPLE)), array(
    'label',
  )) as $key) {
    $form['settings']['display'][$key] = array(
      '#type' => 'value',
      '#value' => isset($group['settings']['display'][$key]) ? $group['settings']['display'][$key] : 'fieldset',
    );
  }
  $form['weight'] = array(
    '#type' => 'hidden',
    '#default_value' => isset($group['weight']) ? $group['weight'] : 0,
  );
  $form['group_name'] = array(
    '#type' => 'hidden',
    '#default_value' => $group_name,
  );
  $form['#content_type'] = $content_type;
  $form['#group_action'] = $action;
  $form['#submit'][] = 'fieldgroup_edit_group_submit';
  return $form;
}