function certificate_field_grouping_form in Certificate 7.3
Same name and namespace in other branches
- 8.3 certificate.admin.inc \certificate_field_grouping_form()
- 6.2 certificate.admin.inc \certificate_field_grouping_form()
- 6 certificate.admin.inc \certificate_field_grouping_form()
- 7.2 certificate.admin.inc \certificate_field_grouping_form()
- 3.x certificate.admin.inc \certificate_field_grouping_form()
Form to select which content profile field values are part of which group.
1 string reference to 'certificate_field_grouping_form'
- certificate_menu in ./
certificate.module - Implements hook_menu().
File
- ./
certificate.admin.inc, line 223 - Administrative pages for Certificate module.
Code
function certificate_field_grouping_form($form, &$form_state) {
$form = array();
$types = field_info_instances('profile2');
$types += field_info_instances('user');
if (!empty($types)) {
$groupsinfo = variable_get('certificate_field_groups', array());
$fieldgroups = variable_get('certificate_field_grouping', array());
$form['map']['#tree'] = TRUE;
// Create multiselect box for each field key.
foreach ($groupsinfo as $key => $title) {
$form['map'][$key] = array(
'#type' => 'fieldset',
'#title' => check_plain($title),
'#tree' => TRUE,
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
foreach ($types as $bundle_name => $fields) {
foreach ($fields as $field) {
$field_info = field_info_field($field['field_name']);
if ($field_info['module'] == 'list') {
$options = list_allowed_values($field_info);
if (!empty($options)) {
$form['map'][$key][$field['field_name']] = array(
'#title' => check_plain($field['label']),
'#type' => 'select',
'#multiple' => TRUE,
'#options' => $options,
// This is a trick to set the default value to ' ', which doesn't
// match anything. This was accidentally causing 'None' to
// actually be selected as a mapping.
'#default_value' => isset($fieldgroups[$key][$field['field_name']]) ? $fieldgroups[$key][$field['field_name']] : array(),
);
}
}
}
}
}
}
else {
$form['disabled']['#markup'] = '<p>' . t('No valid profile fields found on either the core profile entity or Profile2 profiles.') . '</p>';
}
$form['submit'] = array(
'#value' => 'Submit',
'#type' => 'submit',
);
return $form;
}