[html-formfu] some questions

Jim Spath jspath at pangeamedia.com
Fri Sep 7 20:03:14 GMT 2007


Mario Minati wrote:
> On Friday 07 September 2007 17:10:11 Jim Spath wrote:
>> I'm new to HTML::FormFu (never used HTML::Widget) either, and have a
>> couple of questions:
>>
>> The first one is how to easily utilize values which have been altered by
>> FormFu's validation.  An example would be the TrimEdges filter.  If a
>> user enters a value like "  foo  " and we need to redisplay the form, I
>> would like the prefilled value to be "foo".
> The usual behaviour is to give the data back to the user exactly the way he 
> wrote it, returning preprocessed values may confuse him.
> That's also the default behaviour of FormFu.
> 
> I'm not sure if that can be changed. Maybe anyone else can help out.

Hm, I think we can learn to work with the current behavior.

>> Secondly, if I want to add a complex validation routine, like checking
>> to see if a US address is USPS deliverable, is this best done as a
>> callback constraint, or a validator?  If validator, can someone point me
>> to an example of a validator?  The only useful information on validators
>> seemed to be t/validator.t
> Best place would be a validator, regarding to the docs:
> http://search.cpan.org/~cfranks/HTML-FormFu-0.01003/lib/HTML/FormFu.pm#FORM_LOGIC_AND_VALIDATION
> Also from my practice, validator is the right state during the form 
> processing.
> I think the best way to create your own validator is to look in the source 
> code in svn. There is jet no howto or other examples out here, but it's quite 
> easy (tm). Just have a look in the source of the callback-validator.

Ok, I will try implementing the address check as a validator, but I 
guess I'm still a little unclear on when a given check should be run as 
a constraint vs a validator.  I have read the docs, but it doesn't seem 
to be well defined.

Also, the address validation we are using can auto-correct addresses in 
certain cases.  Is it possible for a validator (or a constraint) to 
modify parameter values if necessary?

Thanks again!
- Jim



More information about the HTML-FormFu mailing list