Subject: | Validation not writing error to field error element |
Date: | Tue, 5 Jul 2011 21:43:58 -0700 |
To: | bug-Dancer-Plugin-DataFu [...] rt.cpan.org |
From: | Jason Wieland <jwieland [...] gmail.com> |
DataFu validate returns correctly when checking the validation on field.
However it does not fill in the form->fields->errors array.
If I do a Dumper in the validation sub it looks like it sets it correctly..
EG.
[18032] debug @0.015249> [hit #1]bless( {
Show quoted text
> errors => [
> "Check Email"
> ],
> fields => {
> "contact.comment" => {
> element => {
> type => "textarea"
> },
> errors => [],
> filters => [],
> label => "Comment",
> required => 1,
> validation => sub {
> package Oogly;
> use warnings;
> use strict 'refs';
> 0;
> }
> },
> "contact.email" => {
> element => {
> type => "input_text"
> },
> error => "Check Email",
> errors => [
> "Check Email"
> ],
> filters => [],
> label => "Email",
> name => "contact.email",
> required => 1,
> validation => sub {
> package Dancer::Plugin::DataFu::Form;
> use warnings;
> use strict 'refs';
> my($self, $field, $params) = @_;
> unless ('Email::Valid'->address($$field{'value'})) {
> debug('******* Bad Email **************');
> $self->error($field, $$field{'error'});
> debug(Dumper($self));
> return $self;
> }
> },
> value => "d"
> },
> "contact.name" => {
> element => {
> type => "input_text"
> },
> errors => [],
> filters => [],
> label => "Name",
> required => 1,
> validation => $VAR1->{fields}{"contact.comment"}{validation}
> }
> },
> mixins => {},
> params => {
> "contact.comment" => "",
> "contact.email" => "d",
> "contact.name" => "ddsa",
> splat => [
> "138292989520660"
> ]
> }
> }, 'Oogly::Instance::7REGG' ) in (eval 1022) l. 28
However if I dump the form after it returns to my Dancer routine the errors
array is magically absent
'data' => bless( {
Show quoted text> 'params' => {
> 'contact.name' =>
> 'ddsa',
> 'splat' => [
>
> '138292989520660'
> ],
> 'contact.email' => 'd',
> 'contact.comment' => ''
> },
> 'errors' => [],
> 'mixins' => {},
> 'fields' => {
> 'contact.name' => {
>
> 'errors' => [],
>
> 'required' => 1,
>
> 'filters' => [],
>
> 'validation' => sub { "DUMMY" },
>
> 'label' => 'Name',
>
> 'element' => {
>
> 'type' => 'input_text'
>
> }
> },
> 'contact.email' => {
>
> 'errors' => [],
>
> 'required' => 1,
>
> 'error' => 'Check Email',
>
> 'filters' => [],
>
> 'validation' => sub { "DUMMY" },
>
> 'label' => 'Email',
>
> 'element' => {
>
> 'type' => 'input_text'
>
> }
> },
> 'contact.comment' => {
>
> 'errors' => [],
>
> 'required' => 1,
>
> 'filters' => [],
>
> 'validation' => $form->{'data'}{'fields'}{'contact.name'}{'validation'},
>
> 'label' => 'Comment',
>
> 'element' => {
>
> 'type' => 'textarea'
>
> }
> }
> }
> }, 'Oogly::Instance::1HQCM' ),
> 'settings' => {
> 'grid' => {
> 'profiles' => 'profiles/table'
> },
> 'form' => {
> 'profiles' => 'profiles',
> 'templates' => 'views/datafu'
> }
> },
> 'templates' => {
> 'table' => 'table.tt',
> 'input_checkbox' => 'input_checkbox.tt',
> 'form' => 'form.tt',
> 'directory' =>
> '/home/jason/Workspace/12engines/12engines-service/views/datafu',
> 'thead' => 'thead.tt',
> 'trow' => 'trow.tt',
> 'input_password' => 'input_password.tt',
> 'input_radio' => 'input_radio.tt',
> 'input_text' => 'input_text.tt',
> 'theader' => 'theader.tt',
> 'select_multiple' => 'select_multiple.tt
> ',
> 'select' => 'select.tt',
> 'input_hidden' => 'input_hidden.tt',
> 'tnavigation' => 'tnavigation.tt',
> 'input_file' => 'input_file.tt',
> 'tdata' => 'tdata.tt',
> 'textarea' => 'textarea.tt'
> },
> 'profiles' => [
>
> '/home/jason/Workspace/12engines/12engines-service/profiles/contact.pl'
> ]
> }, 'Dancer::Plugin::DataFu::Form' ); in
> /home/jason/Workspace/12engines/12engines-service/lib/service.pm l. 159
Any assistance is appreciated.
Message body is not shown because it is too large.