Fix Crud's pPFFP and commit the results this time so that I don't lose it and have to explain why I'm redoing 4 hours of painstaking form work with testing. Fixes bug #12382.
This commit is contained in:
parent
4d3056299c
commit
55893c0050
2 changed files with 21 additions and 11 deletions
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue