[Dancer-users] Dancer::Plugin::FormValidator.

igor.bujna at post.cz igor.bujna at post.cz
Tue Oct 12 13:23:31 CEST 2010


Hi,
I look in yours plugin and look very interesive and I will try yours plugin, but I don't think if you use 'halt()' is good option. Better idea if you return undef if everything is OK or hashref in Error. In hasref will be  name of fields and error in this field.
It's better put errors to same form template and write  error or test error  in given error field such as:

get '/contact/form' => sub {
my $error = undef;
if (params->{send}) {
   my $input_hash = {
          Name = $params->{name};
          Subject = $params->{subject};
          Body = $params->{body};
   };

   my $error = form_validator_error( 'profil_contact', $input_hash );
   if ( ! $error ) {
       return template 'form_ok';
   }
}

template 'form', {errors=> $error,.....};
};

template form:

[% IF $errors %]
   put yours error HERE 
[% END %]
<form action="/contact/form" method="get">
  <input type="hiden" name="send" value="1">
  <input type="text" name="body" value="[% params.body %]">
  <input type="text" name="subject" value="[% params.subject %]">
.......
</form>
 
-----------------------------------------------



> ------------ Původní zpráva ------------
> Od: franck <franck at lumberjaph.net>
> Předmět: Re: [Dancer-users] Dancer::Plugin::FormValidator.
> Datum: 12.10.2010 09:31:37
> ----------------------------------------
> Hi
> 
> I have writing my first plugin I got a choice very easy to begin, I
> > think this a good idea. I'm not a good developper at the moment but I
> > hope that will come with experience.
> >
> > My plugin use Data::FormValidator for validate user input. If error was
> > present I return halt() with a message, else I return 0.
> >
> > You can see my plugin here in github
> > http://github.com/hobbestigrou/Dancer-Plugin-FormValidator , if you have
> > any advice or idea.
> >
> >
> Thank you for this module! I wanted something like that for some time but
> didn't had the time to work on this. I'll take a look at the code and see if
> i have some ideas or suggestions.
> 
> 
> 


More information about the Dancer-users mailing list