You are here

function certificate_field_grouping_form in Certificate 6

Same name and namespace in other branches
  1. 8.3 certificate.admin.inc \certificate_field_grouping_form()
  2. 6.2 certificate.admin.inc \certificate_field_grouping_form()
  3. 7.3 certificate.admin.inc \certificate_field_grouping_form()
  4. 7.2 certificate.admin.inc \certificate_field_grouping_form()
  5. 3.x certificate.admin.inc \certificate_field_grouping_form()

Grouping

1 string reference to 'certificate_field_grouping_form'
certificate_field_grouping_page in ./certificate.admin.inc

File

./certificate.admin.inc, line 651
Administrative pages for the module.

Code

function certificate_field_grouping_form() {
  $form = array();
  $form['certificate_field_grouping'] = array(
    '#type' => 'checkbox',
    '#title' => t('Group fields?'),
    '#default_value' => variable_get('certificate_field_grouping', 0),
    '#description' => t('For when there are too many field options to manage individually, group fields to match certificates globally and on certifiable nodes.'),
  );
  if (variable_get('certificate_field_grouping', 0) == 1) {
    $fieldgroups = variable_get('certificate_field_groups', array());
    if (count($fieldgroups)) {

      // Fieldset tree for field groups.
      $form['certificate_field_groups'] = array(
        '#title' => 'Field groups',
        '#type' => 'fieldset',
        '#tree' => TRUE,
      );
    }
    else {
      $form['nogroups'] = array(
        '#prefix' => '<p>',
        '#suffix' => '</p>',
        '#value' => t("No mapped field groups configured."),
      );
    }
    $form['certificate_add_new_group'] = array(
      '#prefix' => '<div>',
      '#suffix' => '</div>',
      '#type' => 'markup',
      '#value' => l('Add a new group?', 'admin/settings/certificate/mapping/groups/add'),
    );

    // Create multiselect box for each field key.
    foreach ($fieldgroups as $key => $fieldgroup) {
      $form['certificate_field_groups'][$key] = array(
        '#title' => $key,
        '#type' => 'select',
        '#multiple' => TRUE,
        '#options' => certificate_get_selected_type_options(),
        '#suffix' => l('Delete ' . $key, "admin/settings/certificate/mapping/groups/delete/{$key}"),
        '#default_value' => $fieldgroup,
      );
    }
  }
  $form['submit'] = array(
    '#value' => 'Submit',
    '#type' => 'submit',
  );
  return $form;
}