You are here

function fieldgroup_edit_group_form in Content Construction Kit (CCK) 5

Same name and namespace in other branches
  1. 6 modules/fieldgroup/fieldgroup.module \fieldgroup_edit_group_form()
5 string references to 'fieldgroup_edit_group_form'
content_copy_export in ./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 ./content_copy.module
Implementation of hook_form_alter(). Intervene to run form through macro when doing export
content_copy_import_form_submit in ./content_copy.module
Submit handler for import form. For each submitted field: 1) add new field to the database 2) execute the imported field macro to update the settings to the imported values
content_copy_record_macro in ./content_copy.module
A handler that stores the form submissions into a $GLOBALS array
fieldgroup_edit_group in ./fieldgroup.module

File

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

Code

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

    //adding a new one
    $group = array();
    $form['submit'] = array(
      '#type' => 'submit',
      '#value' => t('Add'),
      '#weight' => 10,
    );
  }
  else {
    if ($group) {
      $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' => $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' => $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' => $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' => $group['settings']['display']['description'],
    '#rows' => 5,
    '#description' => t('A description of the group.'),
    '#required' => FALSE,
  );
  foreach (array_merge(array_keys(_content_admin_display_contexts()), array(
    'label',
  )) as $key) {
    $form['settings']['display'][$key] = array(
      '#type' => 'value',
      '#value' => $group['settings']['display'][$key],
    );
  }
  $form['weight'] = array(
    '#type' => 'hidden',
    '#default_value' => $group['weight'],
  );
  $form['group_name'] = array(
    '#type' => 'hidden',
    '#default_value' => $group_name,
  );
  $form['#submit'] = array(
    'fieldgroup_edit_group_submit' => array(
      $content_type,
      $action,
    ),
  );
  return $form;
}