Skip to content
Permalink
Browse files

Fix Crud's pPFFP and commit the results this time so that I don't los…

…e it and have to explain why I'm redoing 4 hours of painstaking form work with testing. Fixes bug #12382.
  • Loading branch information...
perlDreamer committed Aug 23, 2012
1 parent 4d30562 commit 55893c00504462300c26786ee51b6b50c4f22da8
Showing with 21 additions and 11 deletions.
  1. +2 −1 docs/changelog/7.x.x.txt
  2. +19 −10 lib/WebGUI/Crud.pm
@@ -1,5 +1,6 @@
7.10.27
- fixed #12379: userImport documentation error
- fixed #12379: userImport documentation error
- fixed #12382: WebGUI::Crud does not work with all form types

7.10.26
- fixed: Template diagnostics when called without a session asset.
@@ -24,6 +24,7 @@ use Clone qw/clone/;
use WebGUI::DateTime;
use WebGUI::Exception;
use WebGUI::Utility;
use WebGUI::Pluggable;

private objectData => my %objectData;
readonly session => my %session;
@@ -991,20 +992,28 @@ sub update {

=head2 updateFromFormPost ( )
Calls update() on any properties that are available from $session->form. Returns 1 on success.
Calls update() on all properties that the object expects.
=cut

sub updateFromFormPost {
my $self = shift;
my $session = $self->session;
my $form = $session->form;
my %data;
my $properties = $self->crud_getProperties($session);
foreach my $property ($form->param) {
$data{$property} = $form->get($property, $properties->{$property}{fieldType}, $properties->{$property}{defaultValue});
}
return $self->update(\%data);
my $self = shift;
my $session = $self->session;
my $form = $session->form;
my $data = $self->get();
my $properties = $self->crud_getProperties($session);
PROPERTY: foreach my $property (keys %{ $properties }) {
my $fieldType = 'WebGUI::Form::'.ucfirst $properties->{$property}{fieldType};
my $control = eval { WebGUI::Pluggable::instanciate($fieldType, "new", [ $self->session, { name => $property, } ]) };
if ($@) {
$self->session->errorHandler->error($@);
next PROPERTY;
}
next PROPERTY if ! $control->isInRequest;
$data->{$property} =
$form->get($property, $properties->{$property}{fieldType}, $properties->{$property}{defaultValue});
}
return $self->update($data);
}


0 comments on commit 55893c0

Please sign in to comment.
You can’t perform that action at this time.