[Catalyst] HTML::Widget, callback constraint, and multiple records per form
Ben Hopkins
hopkins.ben at gmail.com
Fri Sep 1 05:48:36 CEST 2006
Here's what I have: a table (counties) that has county names in it. I want
to be able to add counties. Just one county per screen seems pretty dumb,
so I want a bunch of counties. The sole constraint is that a county cannot
already be in the database, and I figured the Widgets' constraint method
would be perfect for that.
Here I make the widget:
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(&see_if_exists);
}
$w->element('Submit', 'Submit')->value('Submit');
$w->element('Reset');
return $w;
}
Already, I'm wondering where the error message will go. Anyhow, I got
completely lost when writing 'see_if_exists' because the args are
unintelligible. It looks like the second arg is the Catalyst context, and
within there I can find the form results, but if that's the case, why does
it have to be called once for each field? It stops being a field validation
and becomes a form validation called once for each field!?!
Does anybody use callback? Does anybody do multiple create/delete/updates
per form?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.rawmode.org/pipermail/catalyst/attachments/20060831/64b87d5b/attachment.htm
More information about the Catalyst
mailing list