[html-formfu] nested params branch

Mario Minati mario.minati at googlemail.com
Fri Nov 2 23:37:24 GMT 2007


On Friday 26 October 2007 12:41:53 Carl Franks wrote:
> I've created a new branch where I've been adding support for nested
> params, if anyone wants to look / comment.
> http://html-formfu.googlecode.com/svn/branches/nested-params
>
> The form and all block/fieldset element now have a nested_name() method.
> I chose this so as to not conflict with the existing name() method,
> which people may already have been using on blocks for other reasons.
>
> ---
> auto_fieldset:
>   nested_name: foo
> elements:
>   - name: bar
>
> When rendered, this text field would be given the name "foo.bar"
>  -This can be changed to "foo[bar]" by setting $form->nested_subscript(1).
>
> $field->name() would still return "bar".
> A new method, $field->nested_name() would return "foo.bar".
> - nested_name() on fields will die if you try to use it as a setter.
> All template files have been changed to now use 'nested_name'.
>
> You don't need to use Catalyst::Plugin::NestedParams - it shouldn't
> interfere - but it's unnecessary.
> - If you're not using Catalyst, don't use CGI::Expand, as this deletes
> the original "foo.bar" param names, which will break HTML::FormFu.
>
> If you submit:
>     "foo.bar" = 'xyz'
>
> $form->params() would return:
>     {
>       foo => {
>         bar => 'xyz'
>       }
>     }
>
> $form->valid() would return: ( 'foo.bar' )
> $form->valid('foo.bar') would return "1"
>
> $form->param('foo.bar') would return: "xyz"


$form->param('bar') would return undef.
So you always have to use the complete param name.


> * New support for retrieving groups
>
> $form->valid('foo') would return "1" - only if all it's child fields
> have no errors.
> If any of it's child fields have errors, it would return FALSE.
>
> $form->param('foo') would return:
>     {
>       bar => 'xyz'
>     }
> (again, only if all it's child fields have no errors - otherwise it
> would return undef).

Just to clarify.

Greets,
Mario



More information about the HTML-FormFu mailing list