function registration_convert_form_settings in Entity Registration 8.2
Same name and namespace in other branches
- 8 includes/registration.forms.inc \registration_convert_form_settings()
- 7.2 includes/registration.forms.inc \registration_convert_form_settings()
- 7 includes/registration.forms.inc \registration_convert_form_settings()
Helper to convert registration entity settings form values into a fields.
Parameters
$values:
Return value
array
2 calls to registration_convert_form_settings()
- registration_entity_settings_form_submit in includes/
registration.forms.inc - Submit handler for registration_entity_settings_form().
- registration_entity_set_default_settings in ./
registration.module - Sets the the registration entity settings to the deafults.
File
- includes/
registration.forms.inc, line 906 - Form definitions and callbacks for Registration.
Code
function registration_convert_form_settings($values) {
$fields = array(
'status' => $values['status'],
'capacity' => $values['capacity'],
'send_reminder' => isset($values['reminder']['send_reminder']) ? $values['reminder']['send_reminder'] : 0,
'reminder_date' => NULL,
'reminder_template' => isset($values['reminder']['reminder_settings']['reminder_template']) ? $values['reminder']['reminder_settings']['reminder_template'] : NULL,
'settings' => $values['settings'],
'open' => NULL,
'close' => NULL,
);
$date_fields = array(
array(
'name' => 'open',
'label' => 'Open Date',
'set' => 'scheduling',
),
array(
'name' => 'close',
'label' => 'Close Date',
'set' => 'scheduling',
),
);
foreach ($date_fields as $field) {
// Check for token configuration and add to settings.
if (!empty($values[$field['set']][$field['name'] . '_use_token'])) {
$fields['settings'][$field['name'] . '_date_token'] = $values[$field['set']][$field['name'] . '_field'];
}
elseif (!empty($values[$field['set']][$field['name']])) {
$fields[$field['name']] = date('Y-m-d H:i:s', strtotime($values[$field['set']][$field['name']]));
}
}
// Reminder: Reminder Date:
if (!empty($values['reminder']['reminder_settings']['reminder_date'])) {
$fields['reminder_date'] = date('Y-m-d H:i:s', strtotime($values['reminder']['reminder_settings']['reminder_date']));
}
$fields['settings'] = serialize($fields['settings']);
return $fields;
}