Looking at the best way to store a persistent date for individual users.
I have a user/%/date page with the date (module) form field date_select. Its working ok. What I want to know is what would be the best way to save this date for that particular user? variable_set? variable_set doesn't seem to work with the date form field, as it resets to the default date every-time.
How would you save the date so it can be used again simply and from visit to visit? Any sample code would be appreciated to see how its done in 7.
/*
* Include the date api for the form widget and validation.
* Maybe wrong include path????
*/
include 'sites/all/modules/date/date_api/date_api_elements.inc';
/**
* Form builder; Create and display the BD configuration
* settings form.
*/
function bd_form($form, &$form_state) {
// Text field for the BD.
$format = 'Y:F:j';
$form['bd_last_cycle'] = array(
'#type' => 'date_select',
'#title' => t('The last Cycle.'),
'#description' => t('The last time you had a bd.'),
'#date_format' => $format,
'#default_value' => variable_get('bd_last_cycle',
'0000-00-00 0:0:0'),
'#required' => FALSE,
);
// Submit button
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Save settings'),
);
return $form;
}
/**
* Save configuration settings for BD module.
*/