In 4.6 I have a view 'data' that the user fils in. in validate I check it and convert it to a new 'unix' format that 'unix' format is stored in the database.
After loading this unix format is used to build the view.
// simplified example
function clubmember_form(&$node, &$error) {
$output .= form_textfield(t('Birthdate'), 'bdate', $node->bdate, 60, 255, t('The member\'s birthdate (dd-mm-yyyy).'));
return $output;
}
function clubmember_validate(&$node) {
if (!$node->bdate && $node->birthdate)
{
// make sure 'bdate' is set correct when form is created on edit
$node->bdate = format_date($node->birthdate, 'custom', CLUBMEMBER_DATE_FORMAT);
}
if ($node->bdate)
{
$date = $node->bdate;
if ((_clubmember_parsedate($date) != -1) && (strtotime($date) != -1)) {
$node->birthdate = strtotime($date);
}
else {
form_set_error('bdate', t('You have to specify a valid date.'));
return;
}
}
}
function theme_clubmember_view($node, $teaser) {
$output .= '<br />';
if($node->birthdate) {
$output .= '<div class="birthdate"><strong>'.t('Birthday: ').'</strong>'.format_date($node->birthdate, 'custom', CLUBMEMBER_DATE_FORMAT).' <span class="hideprint">('._clubmember_calculate_age($node->birthdate).' '.t("year").')</span></div>';
}
}
I have a problem now in 4.7
When creating a new node the hooks are called after clicking 'preview'