You are here

function birthdays_validate_date_complete in Birthdays 7

Render API callback: Ensures that a given birthdays_date is complete.

If year, month or day are given, everything has to be entered.

This functions is assigned as an #element_validate callback in birthdays_element_info().

2 string references to 'birthdays_validate_date_complete'
birthdays_element_info in ./birthdays.module
Implements hook_element_info().
birthdays_field_widget_form in ./birthdays.module
Implements hook_field_widget_form().

File

./birthdays.module, line 261
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_complete($element, &$form_state) {
  $has_year = !empty($element['#value']['year']);
  $has_month = !empty($element['#value']['month']);
  $has_day = !empty($element['#value']['day']);

  // If something is given, then all has to be given.
  if ($has_year || $has_month || $has_day) {
    if (!(($has_year || $element['#year'] != BIRTHDAYS_HIDE_YEAR_NO) && $has_month && $has_day)) {
      form_error($element, t('The date is not complete.'));
    }
  }
}