"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;