function cer_settings_form in Corresponding Entity References 7.2
Same name and namespace in other branches
- 7 cer.admin.inc \cer_settings_form()
The settings form.
1 string reference to 'cer_settings_form'
- cer_menu in ./
cer.module - Implements hook_menu().
File
- ./
cer.admin.inc, line 11 - Administrative functionality, separated for performance purposes.
Code
function cer_settings_form($form = array(), &$form_state) {
$channels = array();
foreach (_cer_get_fields() as $field) {
// A field that hasn't been instantiated yet will not have a 'bundles' key, which
// means it's useless to us, so skip over it.
if (!isset($field['bundles'])) {
continue;
}
foreach ($field['bundles'] as $entity_type => $bundles) {
foreach ($bundles as $bundle) {
$instance = field_info_instance($entity_type, $field['field_name'], $bundle);
if ($instance) {
$channels = array_merge($channels, _cer_find_channels($instance));
}
}
}
}
if (empty($channels)) {
drupal_set_message(t('There are no entity reference fields that can correspond.'), 'warning');
}
else {
$mapping = array();
foreach ($channels as $count => $key) {
$formatted_key = str_replace(' ', '*', $key);
$mapping[$count] = $formatted_key;
$form['values']["enabled_{$count}"] = array(
'#type' => 'checkbox',
'#default_value' => cer_preset_enabled($formatted_key),
'#title' => filter_xss(theme('cer_label', array(
'key' => $key,
))),
);
}
// We are using a hidden field to submit the configuration because on
// some systems the checkbox name length is limited, and using
// the key would cause the length to be too long. (Issue #558612)
$form['mapping'] = array(
'#type' => 'hidden',
'#value' => serialize($mapping),
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Save'),
);
}
return $form;
}