[Catalyst] edit has_many relation with FormFu

David Schmidt davewood at gmx.at
Fri Oct 24 09:08:46 BST 2008


Hello List.

I want to edit a m:n relation between projects and pictures (a project
may have many pictures). It is displayed correctly but upon submit the
following error message occurs:
NOTE: 7 is the project ID which seems to be interpreted as a column name

DBI Exception: DBD::SQLite::db prepare_cached failed: near ".7":
syntax error(1) at dbdimp.c line 271 [for Statement "SELECT
me.picture_id, me.project_id, me.position FROM picture_projects me
WHERE ( ( ( me.7 IS NULL ) AND ( me.project_id = ? ) ) )"] at
/usr/local/share/perl/5.8.8/DBIx/Class/Schema.pm line 954

in this line in Controller/Projects.pm:
>if ($form->submitted_and_valid) {
>        $form->model->update($project);


Any help is highly appreciated as I am stuck with this problem since a
few days already.

in lib/MyApp/Schema/Projects.pm:
> __PACKAGE__->has_many(picture_projects => 'Oberhumer::Schema::PictureProjects', 'project_id');
> __PACKAGE__->many_to_many(pictures => 'picture_projects', 'picture');

in myapp02.sql:
>CREATE TABLE pictures (
>        id       INTEGER PRIMARY KEY,
>        title    TEXT,
>        info     TEXT,
>        filename TEXT,
>        created  datetime
>);
>
>CREATE TABLE picture_projects (
>        picture_id      INTEGER,
>        project_id      INTEGER,
>        position        INTEGER,
>        PRIMARY KEY (project_id, picture_id)
>);

in root/forms/projects/formfu_create.yml:
>- type: Repeatable
>  nested_name: picture_projects
>  elements:
>    - type: Hidden
>      name: project_id
>    - type: Hidden
>      name: picture_id
>    - type: Text
>      label: Position
>      name: position

with friendly greetings
David Schmidt

-- 
David Schmidt   |   http://www.fm5.at



More information about the Catalyst mailing list