function birthdays_validate_date in Birthdays 7
Render API callback: Validates birthdays_date elements.
Ensures that the supplied date is valid and confirms to the #year setting.
This function is assigned as an #element_validate callback in birthdays_element_info().
3 string references to 'birthdays_validate_date'
- birthdays_element_info in ./
birthdays.module - Implements hook_element_info().
- birthdays_field_views_handler_filter::options_validate in views/
birthdays_field_views_handler_filter.inc - Overrides views_handler_filter_date::options_validate().
- birthdays_field_widget_form in ./
birthdays.module - Implements hook_field_widget_form().
File
- ./
birthdays.module, line 231 - The Birthdays module allows users to add their birthday to their profile. It lists birthdays on a seperate page and in different blocks. Users can receive an email on their birthday automatically, and the administrator can receive daily reminders of…
Code
function birthdays_validate_date($element, &$form_state) {
if (!empty($element['#value']['month']) && !empty($element['#value']['day'])) {
if (empty($element['#value']['year'])) {
if ($element['#year'] == BIRTHDAYS_HIDE_YEAR_NO) {
form_error($element, t('The year is required.'));
}
$element['#value']['year'] = 2000;
}
if (!checkdate($element['#value']['month'], $element['#value']['day'], $element['#value']['year'])) {
form_error($element, t('The specified date is invalid.'));
}
}
else {
if (!empty($element['#required'])) {
form_error($element, t('The birthday field is required.'));
}
}
}