[Catalyst] HTML::Widget, callback constraint, and multiple records per form

Ben Hopkins hopkins.ben at gmail.com
Mon Sep 4 11:06:25 CEST 2006


That did the trick!  Thanks!

On 9/1/06, Jason Kohles <email at jasonkohles.com> wrote:
>
> On 9/1/06, Ben Hopkins <hopkins.ben at gmail.com> wrote:
> > Boy is my face red!
> >
> >  What a stupid mistake!  Thanks for noticing it.
> >
> >  Hmmm.  Makes me think now.  The see_if_exists subroutine now gets the
> value
> > in the form, but doesn't have any context (to do a
> > $c->model('electionsDB::County')->find... call).  If I made
> > a subroutine that returns a coderef to a snippet that has the context in
> it
> > ...
> >
> >
> You can work around that pretty easily, by making the callback an
> inline sub ref...
>
> sub make_counties_widget {
>     my ($self, $c) >
>     my $w >
>     for my $f (1..10) {
>         $w->element('Textfield', "name$f")->label('County Name:');
>         $w->constraint('Callback', "name$f")->callback(sub {
>             my ( $value ) >             return see_if_exists( $value, $c );
>         });
>     }
>
>     $w->element('Submit', 'Submit')->value('Submit');
>     $w->element('Reset');
>     return $w;
> }
>
> --
> Jason Kohles
> email at jasonkohles.com - http://www.jasonkohles.com/
> "A witty saying proves nothing."  -- Voltaire
>
> _______________________________________________
> List: Catalyst at lists.rawmode.org
> Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
> Searchable archive:
> http://www.mail-archive.com/catalyst@lists.rawmode.org/
> Dev site: http://dev.catalyst.perl.org/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.rawmode.org/pipermail/catalyst/attachments/20060904/5766dfea/attachment.htm 


More information about the Catalyst mailing list