function _birthdays_field_widget_textfield_validate in Birthdays 7
Render API callback: Parses a birthday textfield widget value.
This function is assigned as an #element_validate callback in birthdays_field_widget_form().
1 string reference to '_birthdays_field_widget_textfield_validate'
- birthdays_field_widget_form in ./
birthdays.module - Implements hook_field_widget_form().
File
- ./
birthdays.module, line 715 - 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_field_widget_textfield_validate(&$element, &$form_state, $form) {
if (trim($element['value']['#value']) !== '') {
// Parse the string.
switch ($element['#year']) {
case BIRTHDAYS_HIDE_YEAR_NO:
$parsed = date_parse_from_format($element['#dateformat'], $element['value']['#value']);
break;
case BIRTHDAYS_HIDE_YEAR_YES:
$parsed = date_parse_from_format($element['#dateformat_noyear'], $element['value']['#value']);
break;
case BIRTHDAYS_HIDE_YEAR_USER:
$parsed = date_parse_from_format($element['#dateformat'], $element['value']['#value']);
if (empty($parsed['year']) || empty($parsed['month']) || empty($parsed['day'])) {
$parsed = date_parse_from_format($element['#dateformat_noyear'], $element['value']['#value']);
}
break;
}
if (empty($parsed['year'])) {
$parsed['year'] = 0;
}
// Get the trigger settings.
$parsed['triggers'] = $element['triggers']['#value'];
// Set the value on the container element.
$element['#value'] = $parsed;
form_set_value($element, $parsed, $form_state);
}
}