Hi, I am trying to validate an item in a Select field. The field is populated with the first entry as a [0, 'Select a User'] option. I want to ensure that the user has not forgotten to make a selection from this Select field and that the Selection is valid. However I am struggling to get a validation::callback in config to work.
The field is initially populated like this: my @UsersObjs = $c->model('DB::Users')->all() my @users; push(@agents, [ 0,'Select a User']); foreach (sort {$a->name cmp $b->name} @UsersObjs) { push(@agents, [$_->user_id, $_->name]); } my $select = $form->get_element({ type => 'Select'}); $select->options(\...@users); This is how my config file looks at the moment: - type: Select name: agent label: For Agent attributes: title: You must select at least one user validators: - type: Callback callback: "MyApp::Controller::Submissions::user_validator" - type: Submit name: submit value: Add And this is the package that contains the validator. package MyApp::Controller::Submissions; use strict; use warnings; use parent 'Catalyst::Controller::HTML::FormFu' sub user_validator : Local { my ( $val, $params) = @_; print STDERR "In user validator with $val and $params\n"; return 1 if $val != 0; return; } 1; My messages to STDERR are not appearing so the callback cannot be getting as far a MyApp::Controller::Submission. I have tried using 'main::user_validator' but that doesn't make the link either. Can anyone tell me what I am missing please? TIA, Dp. _______________________________________________ HTML-FormFu mailing list HTML-FormFu@lists.scsys.co.uk http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/html-formfu