Bug #33274

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

Added by Zach Davis almost 10 years ago. Updated almost 10 years ago.

Status:
Closed
Priority:
Should have
Assignee:
Category:
ViewHelpers
Target version:
-
Start date:
2012-01-18
Due date:
% Done:

0%

Estimated time:
Has patch:
No

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

Related to TYPO3 Core - Bug #90331: f:hidden does not add identity fieldsClosedStefan Froemken2020-02-05

Actions
Is duplicate of TYPO3.Fluid - Bug #29290: Additional Identity Properties not set on mapping errorResolvedBastian Waidelich2011-08-26

Actions
#1

Updated by Bastian Waidelich almost 10 years ago

  • Status changed from New to Accepted
  • Assignee set to Zach Davis

Hi Zach,

good catch, you're right.

#2

Updated by Zach Davis almost 10 years ago

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

best,
Zach

#3

Updated by Bastian Waidelich almost 10 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

#4

Updated by Stefan Froemken almost 2 years ago

  • Related to Bug #90331: f:hidden does not add identity fields added

Also available in: Atom PDF