[development] Skipping validation on date field
lists at jeffhartman.com
Thu Mar 17 18:16:55 UTC 2011
Yes, I'm using a date element.
I'm doing what you describe in your second option below. When the user doesn't select anything, the date array passed has empty values (in essence is the same as "mushing them into nothing"), and I suspect that is why it doesn't pass validation... because an empty value is not a valid date.
So I assume I need a way to say that no date selected is considered valid.
On Mar 17, 2011, at 12:20 PM, Randy Fay wrote:
> Without completely understanding what you're up to:
> 1. I think you should be using a date *element* to do this if you're not already, so you validate the element as you would expect. But you probably already knew that. (And doesn't the date module provide this?) If not, and you want to roll your own, form_example_elements.inc in the Examples Form Example shows how to do it. You could then use a '#validate' function to short-circuit validation...
> 2. If you're already using a date element to do this, you probably need to make a #validate that mushes the values into nothing when they haven't selected anything. I suspect that you're currently getting a value that doesn't equate to empty after you've changed those form elements.
> Sorry if I've missed the point, but one of those two ought to help.
More information about the development