[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[cgiapp] better msg handling in FormValidator ?


Hi,

i am using C::A::P::ValidateRM and it has been great. one thing i don't like what i am doing is
the way of organizing customized message for form error.

currently i have something like this:

constraint_methods => {
             a_field => sub { my ($dfv, $val) = @_;
                              if $val matches html tag
                                 $dfv->name_is('html_tag_found');
                                 return;
                              } else { return 1 }
             }
}
msgs => {
          prefix      => 'err_',
          any_errors  => 'some_errors',
          constrains => { html_tag_found => 'html tag is not allowed in this field', }
}

a good thing about the above is that, i can use [% err_a_field %] in my template without
conditionaly looking up what exact error it is.

it is okay when i have only one or two forms. but it gets a bit out of hand to maintain the
message system. i already have the real messages stored in a config file instead of hardcoded it
in the module.
also, it seems redundant to have 'html_tag_found' in the constraint_methods and in msgs. 

i am wondering how are other people using DFV and i would like to adopt a simpler and
maintaintable way..


thanks,

James.


       
____________________________________________________________________________________
Got a little couch potato? 
Check out fun summer activities for kids.
http://search.yahoo.com/search?fr=oni_on_mail&p=summer+activities+for+kids&cs=bz 

---------------------------------------------------------------------
Web Archive:  http://www.mail-archive.com/suppressed/
              http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: suppressed
For additional commands, e-mail: suppressed


Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.