[html-formfu] nested params branch

Carl Franks fireartist at gmail.com
Fri Oct 26 11:41:53 GMT 2007


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"

* 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).

At the moment, I've gotten all Constraints working with nested params
- and only the Filters which don't override process().
All the other processors are still needing done.
File uploads are working, but not yet tested under Catalyst.

All tests pass except those relating to the Date element - I've yet to
deal with that.

Any feedback is, as usual, most welcome!

Cheers,
Carl



More information about the HTML-FormFu mailing list