Fix handling of multi-form and multiple select form elements by emitting
a hidden form variable to make sure the form element was in the generated form. Changes in User and ProfileField to support this.
This commit is contained in:
parent
83d1203de9
commit
41da738e0e
9 changed files with 134 additions and 17 deletions
|
|
@ -1170,23 +1170,21 @@ sub validateProfileDataFromForm {
|
|||
my $errorFields = [];
|
||||
my $warnFields = [];
|
||||
|
||||
foreach my $field (@{$fields}) {
|
||||
FIELD: foreach my $field (@{$fields}) {
|
||||
my $fieldId = $field->getId;
|
||||
my $fieldLabel = $field->getLabel;
|
||||
my $fieldValue = $field->formProcess;
|
||||
my $isValid = $field->isValid($fieldValue);
|
||||
|
||||
$data->{$fieldId} = (ref $fieldValue eq "ARRAY") ? $fieldValue->[0] : $fieldValue;
|
||||
|
||||
if(!$isValid) {
|
||||
$errorCat = $field->get("profileCategoryId") unless (defined $errorCat);
|
||||
push (@{$errors}, sprintf($i18n->get("required error"),$fieldLabel));
|
||||
push(@{$errorFields},$fieldId);
|
||||
}
|
||||
#The language field is special and must be always be valid or WebGUI will croak
|
||||
elsif($fieldId eq "language" && !(exists $i18n->getLanguages()->{$data->{$fieldId}})) {
|
||||
elsif($fieldId eq "language" && !(exists $i18n->getLanguages()->{$fieldValue})) {
|
||||
$errorCat = $field->get("profileCategoryId") unless (defined $errorCat);
|
||||
push (@{$errors}, sprintf($i18n->get("language not available error"),$data->{$fieldId}));
|
||||
push (@{$errors}, sprintf($i18n->get("language not available error"),$fieldValue));
|
||||
push(@{$errorFields},$fieldId);
|
||||
}
|
||||
#Duplicate emails throw warnings
|
||||
|
|
@ -1195,6 +1193,11 @@ sub validateProfileDataFromForm {
|
|||
push (@{$warnings},$i18n->get(1072));
|
||||
push(@{$warnFields},$fieldId);
|
||||
}
|
||||
|
||||
##Do not return data unless the form field was actually in the posted data.
|
||||
next FIELD unless $field->isInRequest;
|
||||
$data->{$fieldId} = (ref $fieldValue eq "ARRAY") ? $fieldValue->[0] : $fieldValue;
|
||||
|
||||
}
|
||||
|
||||
return {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue