Skip to content

Commit

Permalink
Fix Crud's pPFFP and commit the results this time so that I don't los…
Browse files Browse the repository at this point in the history
…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 55893c0
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 11 deletions.
3 changes: 2 additions & 1 deletion docs/changelog/7.x.x.txt
@@ -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.
Expand Down
29 changes: 19 additions & 10 deletions lib/WebGUI/Crud.pm
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}


Expand Down

0 comments on commit 55893c0

Please sign in to comment.