[html-formfu] Request advice RE FormFu and join tables

Dennis Daupert ddaupert at gmail.com
Tue Apr 14 02:45:22 GMT 2009


Finding my way around, I thought I'd ask for advice before getting myself in
too much trouble ;-)

I have several sets of parent / child / join tables in which both the
"parent (has many and many-to-many)" and "child (belongs to)" tables are
managed separately, and only the join tables need to be updated; e.g. ,
users, roles, user_roles; projects, directories, project_directories. I am
wondering how to configure forms so that inserts, updates, deletes go to the
join tables? Or is it best to "hand roll" parameter value capturing and
database interactions.

In HTML::FormFu::Model::DBIC I see examples showing yaml configurations for
updating tables that are related to one another -- via foreign keys, but I'm
not sure how to apply the example logic to my situation.

For example, I have a form that has two Selects: projects and directories.
The user will select one project, and could select multiple directories.
Both Projects and Directories tables are prepopulated, so only the
projects_directories join table needs to be modified. Let me paste some bits
from the three tables, snipped for brevity:

=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D
package hde::Schema::Result::Projects;
__PACKAGE__->table("projects");
__PACKAGE__->add_columns(
  "id",   { data_type =3D> "INTEGER", is_nullable =3D> 0, size =3D> undef },
  "rel_tag",   { data_type =3D> "TEXT", is_nullable =3D> 0, size =3D> undef=
 },

__PACKAGE__->has_many(map_project_directory =3D>
'hde::Schema::Result::ProjectDirectories', 'directory_id');
__PACKAGE__->many_to_many(directories =3D> 'map_project_directory',
'directory');

=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D
package hde::Schema::Result::Directories;
__PACKAGE__->table("directories");
__PACKAGE__->add_columns(
  "id",   { data_type =3D> "INTEGER", is_nullable =3D> 0, size =3D> undef },
  "directory",   { data_type =3D> "TEXT", is_nullable =3D> 0, size =3D> und=
ef },

__PACKAGE__->has_many(map_project_directory =3D>
'hde::Schema::Result::ProjectDirectories', 'directory_id');

=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D
package hde::Schema::Result::ProjectDirectories;
__PACKAGE__->table("project_directories");
__PACKAGE__->add_columns(
  "project_id",   { data_type =3D> "INTEGER", is_nullable =3D> 0, size =3D>=
 undef
},
  "directory_id",   { data_type =3D> "INTEGER", is_nullable =3D> 0, size =
=3D>
undef },
__PACKAGE__->belongs_to(project =3D> 'hde::Schema::Result::Projects',
'project_id');
__PACKAGE__->belongs_to(directory =3D> 'hde::Schema::Result::Directories',
'directory_id');

=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D

Is/are there configuration settings that allow FormFu to easily handle this
sort of situation?

/dennis
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/html-formfu/attachments/20090413/e5=
21d99b/attachment.htm


More information about the HTML-FormFu mailing list