Form::Factory::Feature::RequireNoneOrAll - if one control has a value, all should
version 0.013
package MyApp::Action::Foo; our $VERSION = '0.013'; 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 } }
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.
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.
This runs the checks to make sure that for each group of controls, either all have a value or none do.
Andrew Sterling Hanenkamp <hanenkamp@cpan.org>
<hanenkamp@cpan.org>
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.
To install Form::Factory, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Form::Factory
CPAN shell
perl -MCPAN -e shell install Form::Factory
For more information on module installation, please visit the detailed CPAN module installation guide.