-- Michael Peters <[EMAIL PROTECTED]> wrote:

> James.Q.L wrote:
> 
> > i am wondering how are other people using DFV and i would like to adopt a 
> > simpler and
> > maintaintable way..
> 
> I usually have a custom method that I pass as the value for 'msgs' that 
> creates
> a hash of error flags for me. These flags are the name of the field (or the 
> name
> of the constraint if a field has multiple constraints) prefixed by 'err_'. 
> Then
> if it's missing another flag is prefixed by 'missing_' and if it's invalid yet
> another flag is prefixed with 'invalid_'.
> 
> You can see an example of this method in smolder:
> http://smolder.svn.sourceforge.net/viewvc/smolder/trunk/lib/Smolder/Control.pm?view=markup
> starting at line 345.
>
> Then depending on the project I either put the error messages into the 
> template
> (this is what smolder does) and then show the right ones based on the error
> flags present. 

i have looked at smolder dfv error message handling before. i don't like to put 
the error messages
in template. felt like hardcoded it too. esp when you have to do bunch of [% if 
err_a_filed %] ..
[% ELSIF missing_a_filed %] ... 

but it does give you the real flexiablity of setting up customized message.

one question though, if a field (say username) required at least lenght of 6 
and contain only
number and alphabet. how do you show different error based on user input for 
this single filed?

> Or if my needs are more complicated (messages can change more
> often or need to be translated into multiple languages, etc) then I put the
> messages in a config file (Krang does this) where the message's name matches 
> the
> 'missing_' and 'invalid_' error flags.
>

i sorta does it in the dfv form profile, i.e i do 
msgs => {
          constrains => { html_tag_found => 
$self->config_param('form_err.html_tag_found') }
}

but i am looking for a way to do it somewhere else.. will have to look at 
krang's message class.
 
thanks!

> -- 
> Michael Peters
> Developer
> Plus Three, LP
> 
> 

James.


       
____________________________________________________________________________________
Moody friends. Drama queens. Your life? Nope! - their life, your story. Play 
Sims Stories at Yahoo! Games.
http://sims.yahoo.com/  

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

Reply via email to