The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

DBIx::Class::InstantCRUD - Like DBIx::Class::HTMLWidget but handles relationships and extra info in the columns_info metadata. It also has methods to put DBIC objects into HTML

SYNOPSIS

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::User;
   use base 'DBIx::Class';
   __PACKAGE__->load_components(qw/InstantCRUD Core/);

   
   package My::Controller::User;    # Catalyst-style
   
   # this renders an edit form with values filled in from the DB 
   sub do_edit : Local {
     my ($self,$c,$id)=@_;
  
     # get the object
     my $item = $c->model('DBIC::User')->find($id);
     # get the widget
     my $w = $item->get_widget;
     $w->action($c->uri_for('do_edit/'.$id));
     
     # process the widget
     my $result = $w->process($c->request);

     if($result->has_errors){
         $c->stash->{widget} = $result;
         $c->stash->{template} = 'edit';
     } else {
         $item->populate_from_widget($result);
         $c->forward('view');
     }
  
  }
  
  sub edit : Local {
    my ($self,$c,$id)=@_;
    
    # get the object from DB
    my $item=$c->model('DBIC::User')->find($id);
    $c->stash->{item}=$item;
    
    # get the widget
    my $w= $item->get_widget;
    $w->action($c->uri_for('do_edit/'.$id));
    
    # process the widget
    $c->stash->{'result'}= $w->process;
  }

  

DESCRIPTION

Something like DBIx::Class::HTMLWidget but handles relationships and extra info in the columns_info metadata. It also has methods to put DBIC objects into HTML

Methods

populate_from_widget

   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

AUTHORS

Thomas Klausner, <domm@cpan.org>, http://domm.zsi.at

Marcus Ramberg, <mramberg@cpan.org>

Zbigniew Lukasiak> zz bb yy @ gmail.com

Jonas Alves, jonas.alves at gmail.com

CONTRIBUTORS

Simon Elliott, <cpan@browsing.co.uk>

Kaare Rasmussen

Ashley Berlin

LICENSE

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