[html-formfu] defaults_from_model not filling a nested
Checkboxgroup
Carl Franks
fireartist at gmail.com
Sat Dec 15 17:22:43 GMT 2007
On 15/12/2007, Jonas Alves <jonas.alves at gmail.com> wrote:
> Hi Guys,
> I have a form with an element like this:
>
> - type: Block
> tag: ~
> nested_name: area_rel
> elements:
> - type: Checkboxgroup
> name: area_id
> options: [ ... ]
> constraints: [ AutoSet ]
>
> area_rel is a many_to_many relationship defined in my model.
>
>
> And defaults_from_model fails to fill it. Am I doing something wrong, or
> this is not supported yet?
Hi Jonas,
http://search.cpan.org/~cfranks/HTML-FormFu-0.02002/lib/HTML/FormFu/Model/DBIC.pm#many_to_many_selection
You don't need the Block for that:
type: Checkboxgroup
name: area_rel
If area_id is the PK, it'll pick that up automatically, otherwise you
can be explicit:
db: { default_column: area_id }
And this isn't documented yet because it may change, but with the
catalyst controller you can populate the Checkboxgroup from the db
like so:
type: Checkboxgroup
name: area_rel
db:
model: MyModel
label_col: area
See the source of Element/_Group::process() for more details.
Cheers,
Carl
More information about the HTML-FormFu
mailing list