[Catalyst] FormFu many_to_many YAML declaration

brainbuz at brainbuz.org brainbuz at brainbuz.org
Thu Apr 12 15:35:59 GMT 2012


> Hi,
>
> I am having trouble with understanding how to get Many to Many
> relationships into a FormFu form via YAML.
>
> Consider the tutorial example...
> https://metacpan.org/module/Catalyst::Manual::Tutorial::09_AdvancedCRUD::09_FormFu
>
> The authors are placed into a select element.
>
> <snip>
>     } else {
>         # Get the authors from the DB
>         my @author_objs = $c->model("DB::Author")->all();
>         # Create an array of arrayrefs where each arrayref is an author
>         my @authors;
>         foreach (sort {$a->last_name cmp $b->last_name} @author_objs) {
>             push(@authors, [$_->id, $_->last_name]);
>         }
>         # Get the select added by the config file
>         my $select = $form->get_element({type => 'Select'});
>         # Add the authors to it
>         $select->options(\@authors);
>     }
> </snip>
>
> and then in the form set up config
>
> <snip>
>     - type: Select
>       name: authors
>       label: Author
> </snip>
>
>
>
> What if I don't want the authors in a select field but a text field? Can I
> do that?
>
>
> I have been trying to use something like in
> http://search.cpan.org/~pshangov/HTML-FormFu-Model-DBIC-0.09002/lib/HTML/FormFu/Model/DBIC.pm#has_many_and_many_to_many_relationships
>
> but that example schema set does not have the "many-to-many join table
> between books & authors" as in the tutorial.
> https://metacpan.org/module/Catalyst::Manual::Tutorial::03_MoreCatalystBasics#CREATE-A-SQLITE-DATABASE
>
> I can't figure out how to write the YAML to get FormFu to put the data
> into
> my edit form while using the many to many join table. Can anyone help out?
>
> Thanks in advance.
> _______________________________________________
> List: Catalyst at lists.scsys.co.uk
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive:
> http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
> Dev site: http://dev.catalyst.perl.org/
>





More information about the Catalyst mailing list