Skip Menu |

This queue is for tickets about the HTML-FormFu CPAN distribution.

Report information
The Basics
Id: 45409
Status: open
Priority: 0/
Queue: HTML-FormFu

People
Owner: Nobody in particular
Requestors: rod.taylor [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.04000
Fixed in: (no value)



"when" for a checkbox field does not honour "not" when the checkbox has not been clicked. When the checkbox value is not clicked (!defined) then the constraint is still skipped despite the "not" inversion. Simple one line patch below to correct this issue. - type: Text name: fieldname constraints: - type: Required when: field: some_checkbox values: ['it_is_checked'] not: 1 - type: Checkbox label: Skip Required Constraint name: some_checkbox value: it_is_checked *** Constraint.pm.orig Fri Apr 24 19:13:49 2009 --- Constraint.pm Fri Apr 24 19:18:24 2009 *************** *** 140,146 **** # nothing to constrain if field doesn't exist my $when_field_value = $self->get_nested_hash_value( $params, $when_field ); ! return 0 if !defined $when_field_value; my @values; --- 140,146 ---- # nothing to constrain if field doesn't exist my $when_field_value = $self->get_nested_hash_value( $params, $when_field ); ! return $when->{not} ? 1 : 0 if !defined $when_field_value; my @values;
This patch will no longer apply. 6 years later, i suspect you arent fussed? On Fri Apr 24 19:24:18 2009, rtaylor wrote: Show quoted text
> "when" for a checkbox field does not honour "not" when the checkbox has > not been clicked. > > When the checkbox value is not clicked (!defined) then the constraint is > still skipped despite the "not" inversion. Simple one line patch below > to correct this issue. > > - type: Text > name: fieldname > constraints: > - type: Required > when: > field: some_checkbox > values: ['it_is_checked'] > not: 1 > > - type: Checkbox > label: Skip Required Constraint > name: some_checkbox > value: it_is_checked > > > > > > > *** Constraint.pm.orig Fri Apr 24 19:13:49 2009 > --- Constraint.pm Fri Apr 24 19:18:24 2009 > *************** > *** 140,146 **** > > # nothing to constrain if field doesn't exist > my $when_field_value = $self->get_nested_hash_value( $params, > $when_field ); > ! return 0 if !defined $when_field_value; > > my @values; > > --- 140,146 ---- > > # nothing to constrain if field doesn't exist > my $when_field_value = $self->get_nested_hash_value( $params, > $when_field ); > ! return $when->{not} ? 1 : 0 if !defined $when_field_value; > > my @values; >