Consider this situation:

  • A form that uses the date_select element has another field where #required=TRUE.
  • Upon form submission, if the #required field is empty, the form fails validation.
  • The form's own validation function runs after this #required part fails validation.
  • In this form's validation function, the date_select fields are not populated with a DATE_DATETIME because date_select_validate() will not update the field if there has been a validation error at any previous point in execution, even if the date_select field itself is valid.

So, if the form's validation function depends on these fields to be a DATE_DATETIME, it will fail, unless it accounts for the field being a DATE_ARRAY in a situation like this.

The included patch creates a flag for errors, set to TRUE whenever an error occurs within date_select_validate() itself, and checks this flag instead of form_get_errors() to decide whether to populate the field with a DATE_DATETIME.

CommentFileSizeAuthor
date_api_elements_select_validate.patch4.02 KBc.lam

Comments

karens’s picture

Status: Needs review » Fixed

I didn't use this patch but I just committed a bunch of changes to improve the validation of date_select. Thanks!

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.