[html-formfu] FormFu many_to_many YAML declaration

Robyn Jonahs learn.catalyst at gmail.com
Wed Apr 11 17:29:26 GMT 2012


(Also sent to the Catalyst list - sorry if this is cross posting breach of
etiquette)

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 =3D $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 =3D $form->get_element({type =3D> '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/Fo=
rmFu/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_MoreCatalystBasi=
cs#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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/html-formfu/attachments/20120411/1e=
299bb7/attachment.htm


More information about the HTML-FormFu mailing list