The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Form::Factory::Feature::RequireNoneOrAll - if one control has a value, all should

VERSION

version 0.015

SYNOPSIS

  package MyApp::Action::Foo;
  use Form::Factory::Processor;

  use_feature require_none_or_all => {
      groups => { 
          password => [ qw( 
              old_password 
              new_password 
              confirm_password 
          ) ],
      },
  };

  has_control old_password => (
      control  => 'password',
      prediate => 'has_old_password',
  );

  has_control new_password => (
      control => 'password',
  );

  has_control confirm_password => (
      control => 'password',
  );

  sub run {
      my $self = shift;

      if ($self->has_old_password) {
          # change password, we know new_password and confirm_password are set
      }
  }

DESCRIPTION

This feature allows you to make groups of controls work together. If any one of the named controls have a value when checked, then all of them must or the form will be invalid and an error will be displayed.

ATTRIBUTES

groups

This is how the control groups are configured. Each key is used to name a control group and the values are arrays of controls that are grouped together. This way more than one none-or-all requirement can be set on a given form.

At this time, the control group names are ignored, but might be used in the future for linking additional settings together.

METHODS

check

This runs the checks to make sure that for each group of controls, either all have a value or none do.

AUTHOR

Andrew Sterling Hanenkamp <hanenkamp@cpan.org>

COPYRIGHT AND LICENSE

Copyright 2009 Qubling Software LLC.

This library is free software. You can redistribute it and/or modify it under the same terms as Perl itself.