DBIx::Class::FormTools

DBIx::Class::FormTools is a utility module for building forms with multiple related DBIx::Class objects.
Download

DBIx::Class::FormTools Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • David Jack Olrik
  • Publisher web site:
  • http://search.cpan.org/~djo/Class-DBI-FormTools-v0.0.4/lib/Class/DBI/FormTools.pm

DBIx::Class::FormTools Tags


DBIx::Class::FormTools Description

DBIx::Class::FormTools is a utility module for building forms with multiple related DBIx::Class objects. DBIx::Class::FormTools is a utility module for building forms with multiple related DBIx::Class objects.SYNOPSISIn the examples I use 3 objects, a Film, an Actor and a Role. Role is a many to many relation between Film and Actor. package MySchema; use base 'DBIx::Class::Schema'; __PACKAGE__->load_classes(qw); package MySchema::Film; __PACKAGE__->table('films'); __PACKAGE__->add_columns(qw); __PACKAGE__->set_primary_key('id'); __PACKAGE__->has_many(roles => 'MySchema::Role', 'film_id'); package MySchema::Actor; __PACKAGE__->table('films'); __PACKAGE__->add_columns(qw); __PACKAGE__->set_primary_key('id'); __PACKAGE__->has_many(roles => 'MySchema::Role', 'actor_id'); package MySchema::Role; __PACKAGE__->table('roles'); __PACKAGE__->add_columns(qw); __PACKAGE__->set_primary_key(qw); __PACKAGE__->belongs_to(film_id => 'MySchema::Film'); __PACKAGE__->belongs_to(actor_id => 'MySchema::Actor');In your Model class use base qw/DBIx::Class/; __PACKAGE__->load_components(qw/PK::Auto::Pg Core FormTools/);In your view - HTML::Mason example < %init > my $film = $schema->resultset('Film')->find(42); my $actor = $schema->resultset('Actor')->find(24); < /%init > < form > < input name="< % $film->form_fieldname('title', 'o1') => 'Title' % >" type="text" value="< % $film->title % >" / > < input name="< % $film->form_fieldname('length', 'o1') % >" type="text" value="< % $film->length % >" / > < input name="< % $film->form_fieldname('comment', 'o1') % >" type="text" value="< % $film->comment % >" / > < input name="< % $actor->form_fieldname('name', 'o2') % >" type="text" value="< % $actor->name % >" / > In your controller (or cool helper module, used in your controller) my @objects = DBIx::Class::FormTools->formdata_to_objects($querystring); foreach my $object ( @objects ) { # Assert and Manupulate $object as you like $object->insert_or_update; } Requirements: · Perl


DBIx::Class::FormTools Related Software