On Fri, Jan 2, 2009 at 7:40 PM, David Schmidt <[email protected]> wrote: > Hello list > > I have a M:N relationship where each project can have many pictures > and vice-versa. > > (projects) ---* (picture_projects) *--- (pictures) > > If I edit a project I present the user a list of all pictures with > previously selected ones beeing pre-selected. > > In the formfu config file I add all entries (pictures is the > many_to_many relationship of the Project DBIx Schema) > __PACKAGE__->many_to_many( pictures => 'picture_projects', 'picture_id'); > > > projects/create.yml > --------------------------- > model_config: > model: 'DB::Projects' > > - type: Select > name: pictures > label: Pictures > --------------------------- > > When I edit a Project and save it all entries in picture_projects with > project_id of the edited project are deleted and then reinserted. > But what I want is to only delete them if i actually removed them in > the editing process. > > DELETE FROM picture_projects WHERE ( project_id = ? ): '3' > INSERT INTO picture_projects (picture_id, project_id) VALUES (?, ?): '2', '3' > INSERT INTO picture_projects (picture_id, project_id) VALUES (?, ?): '3', '3' > > I would be very pleased about getting help here since I just redid the > entire application and ran into the same problem again.
FormFu is using the set_pictures method that is generated by DBIC for m2m rels and there's probably no better generic implementation for it other than delete + reinsert. If you want your own specialized logic you can override the set_pictures method. -- Eden Cardim Need help with your Catalyst or DBIx::Class project? Code Monkey http://www.shadowcat.co.uk/catalyst/ Shadowcat Systems Ltd. Want a managed development or deployment platform? http://edenc.vox.com/ http://www.shadowcat.co.uk/servers/ _______________________________________________ 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/
