DBIx::Class::HTMLWidget - Like FromForm but with DBIx::Class and HTML::Widget


You'll need a working DBIx::Class setup and some knowledge of HTML::Widget and Catalyst. If you have no idea what I'm talking about, check the (sparse) docs of those modules.

   package My::Model::DBIC::Pet;
   use base 'DBIx::Class';
   __PACKAGE__->load_components(qw/HTMLWidget Core/);

   package My::Controller::Pet;    # Catalyst-style
   # define the widget in a sub (DRY)
   sub widget_pet {
     my ($self,$c)=@_;
     my $w=$c->widget('pet')->method('get');
     return $w;
   # this renders an edit form with values filled in from the DB 
   sub edit : Local {
     my ($self,$c,$id)=@_;
     # get the object
     my $item=$c->model('DBIC::Pet')->find($id);
     # get the widget
     my $w=$self->widget_pet($c);
     # fill widget with data from DB
  sub do_edit : Local {
    my ($self,$c,$id)=@_;
    # get the object from DB
    my $item=$c->model('DBIC::Pet')->find($id);
    # get the widget
    my $w=$self->widget_pet($c);
    # process the form parameters
    my $result = $w->process($c->req);
    # if there are no errors save the form values to the object
    unless ($result->has_errors) {




Something like Class::DBI::FromForm / Class::DBI::FromCGI but using HTML::Widget for form creation and validation and DBIx::Class as a ORM.




Fill the values of a widgets elements with the values of the DBIC object.


   my $obj=$schema->resultset('pet)->new->populate_from_widget($result);
   my $item->populate_from_widget($result);

Create or update a DBIx::Class row from a HTML::Widget::Result object


Thomas Klausner, <>,

Marcus Ramberg, <>


Simon Elliott, <>

Ashley Berlin


This code is Copyright (c) 2003-2006 Thomas Klausner. All rights reserved.

You may use and distribute this module according to the same terms that Perl is distributed under.