[html-formfu] nested params merged

Mario Minati mario.minati at googlemail.com
Fri Nov 2 23:30:51 GMT 2007


On Tuesday 30 October 2007 12:57:17 Carl Franks wrote:
> I've merged the nested-params branch back into trunk.
>
> Although there's extensive new tests, I haven't tried it out with a
> real application yet - so there may be some teething issues.
> Documentation's still needing done.
>
> Some of the template files have been changed - as they need to use
> 'nested_name' now rather than 'name'. (The next thing I'm going to
> work on will make it easier to use templates and easier to upgrade
> HTML::FormFu).
>
> To expand on the examples in my last mail...
>
> You can set a Form or Block elements nested_name().
> You still just set name() on fields.
>
> $field->nested_name() returns the full name that'll be used in the form
> markup.
>
> If you set $form->nested_subscript(1), elements names will have the
> form "foo[bar][baz]" instead of "foo.bar.baz"
>
> If a field-name or intermediary nested name is an integer, the data
> structure returned by $form->params() or $form->param() will be an
> array-ref:
>
> "foo.bar.0" => 1
> "foo.bar.1" => 2
>
> If you're using any of the Callback processors, or have written your
> own processors (constraints, validators, etc) - they generally get the
> relevant input value as their 1st argument, and the $params hash-ref
> as their 2nd argument.
> Because the $params hash-ref is no longer a single-depth hash, but may
> contain nested structures, you should no longer simply do stuff like
> this:
>     $foo = $params->{foo};
>     $params->{foo} = $foo;
>     if ( exists $params->{foo} ) { }
>
> You should instead use the following helper methods:
>
>     $foo = $self->get_nested_hash_value(
>         $params, $nested_name );
>
>     $self->set_nested_hash_value(
>         $params, $nested_name, $value );
>
>     if ( $self->nested_hash_key_exists(
>         $params, $nested_name ) )
>     { }
>
> Um, that's all I can think of for now...

So now I catched up with your improvements of the last couple days.

One question on Elements::_Field::nested_names:
When $self->name is undefined the function returns a list with undef. Why is 
that?

Did you currently look in DBIx::Class::HTML::FormFu?
Any suggestions on the syntax to select a special nested param tree?
Shall I remove the prefix and suffix stuff when nested params work or keep it 
for a while?

Thanks for taking over the nested param stuff, that was really a big deal.
Well done!

Greets,
Mario



More information about the HTML-FormFu mailing list