Bug #33274

Viewhelpers extending AbstractFormFieldViewHelper should add additionalIdentityProperties even if there is an error on the field

Added by Zach Davis over 3 years ago. Updated over 3 years ago.

Status:Closed Start date:2012-01-18
Priority:Should have Due date:
Assigned To:Zach Davis % Done:

0%

Category:ViewHelpers
Target version:-
Has patch:No Affected Flow version:FLOW3 1.0.2

Description

In a FLOW3 app, I have a form that has fields that reference an Account object and the Party property on the account object. This works fine because when Fluid renders form fields it calls the addAdditionalIdentityPropertiesIfNeeded in the AbstractFormFieldViewHelper class, which adds hidden identity fields for the properties.

However, when any part of the form is invalid a mapping error is triggered. The form field viewhelper sees the mapping error and no longer adds the property identities, which leads to a situation where the user corrects the error in the form, only to have FLOW3 try to create new property objects.

The fix is simple, and I think it's a no-brainer. We need to change the conditional logic in the getValue method on the AbstractFormFieldViewHelper from this:


if ($this->hasArgument('value')) {
$value = $this->arguments['value'];
} elseif ($this->hasMappingErrorOccured()) {
$value = $this->getLastSubmittedFormData();
} elseif ($this->isObjectAccessorMode() && $this->viewHelperVariableContainer->exists('TYPO3\Fluid\ViewHelpers\FormViewHelper', 'formObject')) {
$this->addAdditionalIdentityPropertiesIfNeeded();
$value = $this->getPropertyValue();
}

To this:


if ($this->hasArgument('value')) {
$value = $this->arguments['value'];
} elseif ($this->hasMappingErrorOccured()) {
$this->addAdditionalIdentityPropertiesIfNeeded();
$value = $this->getLastSubmittedFormData();
} elseif ($this->isObjectAccessorMode() && $this->viewHelperVariableContainer->exists('TYPO3\Fluid\ViewHelpers\FormViewHelper', 'formObject')) {
$this->addAdditionalIdentityPropertiesIfNeeded();
$value = $this->getPropertyValue();
}

Notice that we've added the call to addAditionalIdentityPropertiesIfNeeded to the second section of the statement. Even if there's an error, we should still add identity properties, right?

If the change sound right, let me know and I'll submit a patch to gerrit.

Zach


Related issues

duplicates TYPO3.Fluid - Bug #29290: Additional Identity Properties not set on mapping error Resolved 2011-08-26

History

#1 Updated by Bastian Waidelich over 3 years ago

  • Status changed from New to Accepted
  • Assigned To set to Zach Davis

Hi Zach,

good catch, you're right.

#2 Updated by Zach Davis over 3 years ago

Ok, I'll submit a patch to Gerrit today or tomorrow, as time permits.

best,
Zach

#3 Updated by Bastian Waidelich over 3 years ago

  • Status changed from Accepted to Closed

Just found out, that this is a duplicate of the (older) issue #29290
@Zach I'll take care of this one

Also available in: Atom PDF