Form-Processor-Model-DBIC
view release on metacpan or search on metacpan
lib/Form/Processor/Model/DBIC.pm view on Meta::CPAN
The actual update is done in the C<update_model> method. Your form class can
override that method (but don't forget to call SUPER) if you wish to do additional
database inserts or updates. This is useful when a single form updates
multiple tables, or there are secondary tables to update.
Returns false if form does not validate, otherwise returns 1. Very likely dies on database errors.
=cut
sub update_from_form {
my ( $self, $params ) = @_;
return unless $self->validate($params);
$self->schema->txn_do( sub { $self->update_model } );
return 1;
}
=head2 model_validate
The place to put validation that requires database-specific lookups.
Subclass this method in your form.
lib/Form/Processor/Model/DBIC.pm view on Meta::CPAN
accessors in your result source class. It identifies form fields as 1) column,
2) relationship, 3) other. Column and other fields are processed and update
is called on the row. Then relationships are processed.
If the row doesn't exist (no primary key or row object was passed in), then
a row is created using "create" and the fields identified as columns passed
in a hashref, followed by "other" fields and relationships.
=cut
sub update_model {
my ($self) = @_;
my $item = $self->item;
my $source = $self->source;
# get a hash of all fields, skipping fields marked 'noupdate'
my $prefix = $self->name_prefix;
my %columns;
my %multiple_m2m;
my %other;
my $field;
( run in 0.290 second using v1.01-cache-2.11-cpan-4d4bc49f3ae )