[Catalyst] FormValidator and FV_eq_with constraint method
darrenferguson
df at darren-ferguson.com
Wed Nov 26 16:12:14 GMT 2008
Hi,
I am relatively new to Catalyst and am having trouble getting the FV_eq_with
constraint method of Data::FormValidator to work.
my $f = $c->form(
required => [qw/email password/],
constraint_methods => {
email => [
email()
],
password => FV_eq_with('confirm_password')
},
filters => ['trim']
);
Data::Dumper output of the form method return value:
[debug] $VAR1 = bless( {
'profile' => {
'dependencies' => {},
'filters' => [
'trim'
],
'defaults_regexp_map' => {},
'constraint_method_regexp_map' => {},
'constraint_methods' => {
'email' => [
sub {
"DU
MMY" }
],
'password' => sub
{ "D
UMMY" }
},
'dependency_groups' => {},
'constraint_regexp_map' => {},
'constraints' => {},
'required' => [
'email',
'password'
],
'require_some' => {},
'field_filter_regexp_map' => {},
'field_filters' => {}
},
'validate_invalid' => [
[
'email',
'email'
],
'password'
],
'__FILTERED_DATA' => {},
'__INPUT_DATA' => {
'email' => 'sa',
'password' => 'a',
'confirm_password' => 'a',
'security_image' => '',
'submit' => 'submit'
},
'missing' => {},
'__CURRENT_CONSTRAINT_FIELD' => 'password',
'__CURRENT_CONSTRAINT_VALUE' => 'a',
'valid' => {},
'__CURRENT_CONSTRAINT_NAME' => 'eq_with',
'__UNTAINT_THIS' => 0,
'unknown' => {
'confirm_password' => 'a',
'submit' => 'submit'
},
'invalid' => {
'email' => [
'email'
],
'password' => [
'eq_with'
]
}
}, 'Data::FormValidator::Results' );
I went into the Data::FormValidators Constraints.pm and found the constraint
routine.
sub FV_eq_with {
my ($other_field) = @_;
return sub {
my $dfv = shift;
$dfv->name_this('eq_with');
my $curr_val = $dfv->get_current_constraint_value;
my $data = $dfv->get_filtered_data;
# Sometimes the data comes through both ways...
my $other_val = (ref $data->{$other_field}) ?
$data->{$other_field}[0] : $data->{$other_field};
return ($curr_val eq $other_val);
}
}
By hacking around in here, i can see that the reference to the
Data::FormValidator $dfv is not being passed.
Does anyone have any pointers to help me get this working.
Many Thanks.
Darren.
--
View this message in context: http://www.nabble.com/FormValidator-and-FV_eq_with-constraint-method-tp20703984p20703984.html
Sent from the Catalyst Web Framework mailing list archive at Nabble.com.
More information about the Catalyst
mailing list