[html-formfu] Re: DBIC::Validation::FormFu RFC & Element::Date
patch
Carl Franks
fireartist at gmail.com
Mon Oct 22 17:23:04 GMT 2007
Jonas,
On 20/10/2007, Jonas Alves <jonas.alves at gmail.com> wrote:
>
> Hi Carl,
> The 'date' parameter is created only if 'date.*' parameters are passed to
> process. But dbic deletes them, so FormFu never gets anything about the date
> field.
Okay, I understand; because you're passing $c->req->params to
create(), by the time your DBIC::Validation::FormFu gets the params,
they've already been censored (?) by DBIC, so there's nothing for
FormFu to expand.
> How is the work on nested-params going? How would it work? Some months ago I
> wrote something about nested-params to the HTML::Widget list but never got a
> response. See
> http://lists.scsys.co.uk/pipermail/html-widget/2007-April/000602.html.
> Will it work something like that?
I'll have a go at adding the nested-params support over the next day or so.
If I don't get it done, then I'll push out another cpan release, and
then apply your patch. (I'm not wanting the patch in a cpan release,
because I don't know want to break anything if it ends up not working
quite like that.)
You'll probably have to explicitly set either
$form->nested(1)
or
$fieldset->nested(1)
to get the behaviour, so that people can't completely break your
application just by changing param names and feeding hashes into code
that isn't expecting them.
While I like the idea of getting repetitive code out of the
controller, there are several aspects to the proposal I don't like.
I'd rather let Catalyst::Controller::HTML::FormFu handle creating the
forms, at least then you can set global config in the applications
myapp.yml file, such as:
'Controller::HTML::FormFu':
constructor:
render_class_args:
ENCODING: UTF-8
Whereas, it looks like that'll all have to be repeated for
DBIx::Class::Validation
The problem you've had is because you're having to pass
$c->req->params to create(), rather than $form->params.
I'd much prefer something like:
$schema->create( $c->stash->{form}->params )
if $c->stash->{form}->submitted_and_valid;
It's not clear whether you use different actions for displaying the
form and then handling the form.
I like to use the same action for both, partly so that I can let
Catalyst::Controller::HTML::FormFu automatically fill in the form's
action url.
I'm also not too keen on seeing the form object being thrown as an exception.
I'd expect a new exception class to be created for that.
I'm attempting to make time now to look at DBIC integration as a
whole, as I feel there's lots of parts that scratch individual itches,
but there's not a good generic solution yet.
Carl
More information about the HTML-FormFu
mailing list