[html-formfu] Date element validation

Michele Beltrame mb at cattlegrid.info
Thu Jun 12 22:57:37 BST 2008


Hi Ronald!

> If the only error in the submissions is an invalid date, then the form will 
> be rendered with the "Invalid date" error message, as expected. However, if 
> there are any other errors in the submission (such as a missing required 
> field), then only those error messages are displayed; the invalid date 
> error is not generated.
> I feel that this makes for a poor user experience, because it adds an extra 
> step for the user to fix all the errors.

This is because Inflators are not evaluated if there are unsatisfied
Constraints. You're right it makes the user experience poor, as he(/
thinks a field is OK and then discovers it isn't.

What I do is to also have a callback Constraint which converts the
date/time field into a DateTime object and returns error if the
conversion is not successful. I often use this Constraint also to
perform other checks (i.e. for the date not to be in the future,
etc...). After that, I also use the Inflator in order to get a
DateTime object once the form processing is finished.

This gives the user the experience he/she expects.

I know that doing the conversion 2 times might seem a little awkward,
but it seems that the way FormFu is meant to be: the Inflators stage
doesn't happen before the Constraints stage has compelted succesfully.

It would maybe be nice to have a "force_all_stages" option which would
go one with processing in any case, but I don't know enough of FormFu
internals to understand if it's easy or even possible to implement.

Michele.

-- 
Michele Beltrame
http://www.cattlegrid.info/
ICQ 76660101 - MSN mb at italpro.net



More information about the HTML-FormFu mailing list