I am developing a Perl/Catalyst web app using HTML::FormHandler for forms. I am trying to do a conditional validation on a field if a checkbox is checked.
The code below is from a Role I created for my form to use.
has_field 'autosys_jobs.schedule.has_run_day_of_month' => ( type=>'Boolean');
has_field 'autosys_jobs.schedule.run_day_of_month' => ( type => 'PosInteger');
#Validation function for 'autosys_jobs.schedule.run_day_of_month'
sub validate_autosys_jobs_schedule_run_day_of_month {
my ( $self, $field ) = @_;
if( $self->field('autosys_jobs.schedule.has_run_day_of_month')->value ) {
#validate 'autosys_jobs.schedule.run_day_of_month'
}
}
The problem I'm having is that $self->field('autosys_jobs.schedule.has_run_day_of_month')->value
for the boolean field always returns 0 even if it's checked.
Any ideas on what I'm doing wrong?