Hi David,

> 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
>

What does the rest of formfu_create.yml contain?

I've seen the same problem. I vaguely recall needing a model_config
section in the formfu config, something like this (as a perl hash):

{       type => 'Fieldset', legend=>'Plant Zones', elements => [
                                {
                                        type            => 'Repeatable',
                                        nested_name     =>      'plant_zones',

                                        model_config    =>      {
                                                model                           
=>      'DB::PlantZones',
                                                new_empty_row_multi     =>      
'zone_id',
                                        },

                                        attributes      =>      {
                                                class           =>      
'zone-block',
                                        },

                                        elements        =>      [
                                                {
                                                        type    =>      
'Hidden',
                                                        name    =>      'id',
                                                },

... etc...

- Chris

_______________________________________________
List: [email protected]
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[email protected]/
Dev site: http://dev.catalyst.perl.org/

Reply via email to