function registration_field_instance_settings_form in Entity Registration 7
Same name and namespace in other branches
- 8.2 includes/registration.field.inc \registration_field_instance_settings_form()
- 8 includes/registration.field.inc \registration_field_instance_settings_form()
- 7.2 includes/registration.field.inc \registration_field_instance_settings_form()
Implements hook_field_instance_settings_form().
Add default registration field instance settings.
File
- includes/
registration.field.inc, line 51 - Field hooks.
Code
function registration_field_instance_settings_form($field, $instance) {
$form = $form_state = array();
$default_settings = isset($instance['settings']['default_registration_settings']) ? $instance['settings']['default_registration_settings'] : array();
// Flatten scheduling and reminder settings since this form is in tree mode.
foreach ($default_settings as $key => $val) {
if ($key != 'settings' and is_array($val)) {
foreach ($val as $key1 => $val1) {
if (is_array($val1)) {
foreach ($val1 as $key2 => $val2) {
$default_settings[$key2] = $val2;
}
}
else {
$default_settings[$key1] = $val1;
}
}
unset($default_settings[$key]);
}
}
$settings_form = registration_entity_settings_form($form, $form_state, $default_settings);
$form['default_registration_settings'] = array(
'#type' => 'fieldset',
'#title' => t('Default Registration settings'),
'#collapsible' => TRUE,
'#description' => t("These settings will be applied when an entity with this field is saved and does not yet have its own settings applied."),
);
// Unset the save button just in case.
unset($settings_form['save']);
$form['default_registration_settings'] += $settings_form;
$form['hide_register_tab'] = array(
'#type' => 'checkbox',
'#title' => t('Hide Register Tab'),
'#default_value' => isset($instance['settings']['hide_register_tab']) ? $instance['settings']['hide_register_tab'] : 0,
'#required' => FALSE,
'#description' => t('Hide the tab on the content displaying the registration form. The form can still be embedded or linked to by changing the field display settings.'),
);
// @todo: validation
return $form;
}