Catalyst::Manual::Tutorial::AdvancedCRUDCatalyst::Manual::Tutorial::AdvancedCRUD is a Catalyst Tutorial - Part 8: Advanced CRUD. | |
Download |
Catalyst::Manual::Tutorial::AdvancedCRUD Ranking & Summary
Advertisement
- License:
- Perl Artistic License
- Price:
- FREE
- Publisher Name:
- Kennedy Clark
- Publisher web site:
- http://search.cpan.org/~mramberg/Catalyst-Runtime-5.7012/lib/Catalyst/Manual/Installation/CentOS4.pod
Catalyst::Manual::Tutorial::AdvancedCRUD Tags
Catalyst::Manual::Tutorial::AdvancedCRUD Description
Catalyst::Manual::Tutorial::AdvancedCRUD is a Catalyst Tutorial - Part 8: Advanced CRUD. Catalyst::Manual::Tutorial::AdvancedCRUD is a Catalyst Tutorial - Part 8: Advanced CRUD.Add a Form Creation Helper MethodOpen lib/MyApp/Controller/Books.pm in your editor and add the following method: =head2 make_book_widget Build an HTML::Widget form for book creation and updates =cut sub make_book_widget { my ($self, $c) = @_; # Create an HTML::Widget to build the form my $w = $c->widget('book_form')->method('post'); # Get authors my @authorObjs = $c->model("MyAppDB::Author")->all(); my @authors = map {$_->id => $_->last_name } sort {$a->last_name cmp $b->last_name} @authorObjs; # Create the form feilds $w->element('Textfield', 'title' )->label('Title')->size(60); $w->element('Textfield', 'rating' )->label('Rating')->size(1); $w->element('Select', 'authors')->label('Authors') ->options(@authors); $w->element('Submit', 'submit' )->value('submit'); # Return the widget return $w; }This method provides a central location that builds an HTML::Widget-based form with the appropriate fields. The "Get authors" code uses DBIC to retrieve a list of model objects and then uses map to create a hash where the hash keys are the database primary keys from the authors table and the associated values are the last names of the authors. Requirements: · Perl
Catalyst::Manual::Tutorial::AdvancedCRUD Related Software