[Catalyst] Help following instructions - FormFu issues

Carl Franks fireartist at gmail.com
Fri Sep 21 08:05:21 GMT 2012


On 21 September 2012 00:17, Derek W <derekwrobel at gmail.com> wrote:
> Hi All,
>
> I am following the instructions from this tutorial:
> http://search.cpan.org/~zarquon/Catalyst-Manual-5.9004/lib/Catalyst/Manual/Tutorial/09_AdvancedCRUD/09_FormFu.pod
>
> But am using my own database.  I have a MS SQL database with 3 tables (no
> primary keys) linked as follows:
> Table: Groups
> Columns: Groupid, Groupname, GroupDescription
>
> Table: GroupsHosts
> Columns: Groupid, Hostid
>
> Table: Hosts
> Columns: Hostid, HostName, HostIPAddress
>
> Because these tables do not have a primary key set, to have Catalyst
> function correctly, I had to manually add:
> __PACKAGE__->set_primary_key( "hostid" );
>
> and so forth for the groups and hosts schema\result\*.pm files
>
> Everything in the tutorial so far has been working well and I am at the
> point where I want to have more advanced CRUD in my application.
>
> I can manually add a host, including a free text field that allows entry of
> groupid, so that on creation of the host, it also inserts a record into the
> groupshosts table.
>
> However, trying to use this more advanced FormFu, following the exact steps,
> I am able to get the form, with groups list box, but upon save, only the
> host gets saved, and no group information is saved.  No errors are produced
> either.
>
> I was trying to understand the steps in this tutorial, and do not even see
> any place in this tutorial for FormFu that would also save the
> groupid/hostid information to my groupshosts table.  Is this because when
> relationships are properly set up, FormFu can automatically handle this and
> knows to save the groupid in the groupshosts table?
>
> Do you know what I am missing that I cannot get the groupid entry to be
> saved?
>
> I would have thought the code in the controller for this formfu_create would
> need code besides the $form->model->update($host); to save the groupid as
> well.

Hi Derek,

Your DBIx::Class resultsets must have the relationships defined.
See http://search.cpan.org/~frew/DBIx-Class-0.08200/lib/DBIx/Class/Relationship.pm

See also the HTML::FormFu::Model::DBIC docs for how to define your
form for each of the different types of relationships (so it knows how
the form fields relate to the DBIC rels and columns)
http://search.cpan.org/~pshangov/HTML-FormFu-Model-DBIC-0.09002/lib/HTML/FormFu/Model/DBIC.pm

If you have further problems, you'll probably be better off posting to
the html-formfu list
http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/html-formfu

Cheers,
Carl



More information about the Catalyst mailing list