Unix and Linux Discussions Tagged with colum |
|
Thread / Thread Starter |
Last Post |
Replies |
Views |
Forum |
|
|
|
4 |
3,650 |
UNIX for Beginners Questions & Answers |
|
|
|
5 |
2,853 |
UNIX for Beginners Questions & Answers |
|
|
|
0 |
2,168 |
UNIX for Beginners Questions & Answers |
|
|
|
1 |
11,614 |
Shell Programming and Scripting |
|
|
|
4 |
5,272 |
UNIX for Beginners Questions & Answers |
|
|
|
1 |
2,256 |
UNIX for Beginners Questions & Answers |
|
|
|
3 |
2,646 |
UNIX for Beginners Questions & Answers |
|
|
|
9 |
3,964 |
UNIX for Beginners Questions & Answers |
|
|
|
2 |
11,277 |
Programming |
|
|
|
3 |
2,499 |
UNIX for Beginners Questions & Answers |
|
|
|
2 |
3,174 |
UNIX for Beginners Questions & Answers |
|
|
|
4 |
1,800 |
UNIX for Beginners Questions & Answers |
|
|
|
6 |
3,079 |
UNIX for Beginners Questions & Answers |
|
|
|
2 |
4,940 |
Shell Programming and Scripting |
|
|
|
3 |
5,121 |
Shell Programming and Scripting |
|
|
|
6 |
12,996 |
UNIX for Advanced & Expert Users |
|
|
|
7 |
3,949 |
Shell Programming and Scripting |
|
|
|
5 |
1,549 |
UNIX for Beginners Questions & Answers |
|
|
|
2 |
634 |
UNIX for Beginners Questions & Answers |
|
|
|
3 |
2,348 |
UNIX for Advanced & Expert Users |
|
|
|
2 |
4,290 |
Shell Programming and Scripting |
|
|
|
5 |
1,061 |
Shell Programming and Scripting |
|
|
|
6 |
1,301 |
Shell Programming and Scripting |
|
|
|
4 |
1,659 |
Programming |
|
|
|
12 |
3,862 |
Shell Programming and Scripting |
|
|
|
7 |
3,285 |
Shell Programming and Scripting |
|
|
|
5 |
3,818 |
Shell Programming and Scripting |
|
|
|
2 |
2,759 |
UNIX for Dummies Questions & Answers |
|
|
|
7 |
5,357 |
Shell Programming and Scripting |
|
|
|
2 |
1,801 |
UNIX for Advanced & Expert Users |
|
|
|
3 |
3,583 |
Shell Programming and Scripting |
|
|
|
4 |
7,868 |
Shell Programming and Scripting |
|
|
|
2 |
2,107 |
Shell Programming and Scripting |
|
|
|
9 |
6,819 |
UNIX for Dummies Questions & Answers |
|
|
|
1 |
1,908 |
UNIX for Advanced & Expert Users |
|
|
|
8 |
4,941 |
UNIX for Dummies Questions & Answers |
|
|
|
2 |
2,069 |
UNIX for Dummies Questions & Answers |
|
|
|
1 |
3,995 |
Shell Programming and Scripting |
|
|
|
5 |
10,140 |
Shell Programming and Scripting |
|
|
|
5 |
2,212 |
Shell Programming and Scripting |
DBIx::Class::HTMLWidget(3pm) User Contributed Perl Documentation DBIx::Class::HTMLWidget(3pm)
NAME
DBIx::Class::HTMLWidget - Like FromForm but with DBIx::Class and HTML::Widget
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::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');
$w->element('Textfield','name')->label('Name');
$w->element('Textfield','age')->label('Age');
...
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);
$c->stash->{item}=$item;
# get the widget
my $w=$self->widget_pet($c);
$w->action($c->uri_for('do_edit/'.$id));
# fill widget with data from DB
$item->fill_widget($w);
}
sub do_edit : Local {
my ($self,$c,$id)=@_;
# get the object from DB
my $item=$c->model('DBIC::Pet')->find($id);
$c->stash->{item}=$item;
# get the widget
my $w=$self->widget_pet($c);
$w->action($c->uri_for('do_edit/'.$id));
# process the form parameters
my $result = $w->process($c->req);
$c->stash->{'result'}=$result;
# if there are no errors save the form values to the object
unless ($result->has_errors) {
$item->populate_from_widget($result);
$c->res->redirect('/users/pet/'.$id);
}
}
DESCRIPTION
Something like Class::DBI::FromForm / Class::DBI::FromCGI but using HTML::Widget for form creation and validation and DBIx::Class as a ORM.
Methods
fill_widget
$dbic_object->fill_widget($widget);
Fill the values of a widgets elements with the values of the DBIC object.
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
CAEVATS
/ POSSIBLE PROBLEMS
PostgreSQL
ERROR: null value in column "private" violates not-null constraint
This is a result of we trying to set a value to undef that should not be. This is typicaly a problem when you have a colum such ass
"private boolean not null". We have a special-case for this, and if you set data_type => boolean, is_nullable => 0 in your ResultSource
definition, we update the value to 0 before attempting to insert or update
AUTHORS
Thomas Klausner, <domm@cpan.org>, http://domm.zsi.at
Marcus Ramberg, <mramberg@cpan.org>
Andreas Marienborg, <omega@palle.net>
CONTRIBUTORS
Simon Elliott, <cpan@browsing.co.uk>
Ashley Berlin
Guillermo Sansovic
LICENSE
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.
perl v5.10.0 2008-02-06 DBIx::Class::HTMLWidget(3pm)