Bug #29290

Additional Identity Properties not set on mapping error

Added by Torsten no-lastname-given almost 4 years ago. Updated almost 2 years ago.

Status:Resolved Start date:2011-08-26
Priority:Must have Due date:
Assigned To:Bastian Waidelich % Done:

100%

Category:ViewHelpers
Target version:-
Has patch:Yes Affected Flow version:FLOW3 1.0.0

Description

After a mapping error occurred, no additional identity properties are set and FLOW3 tries to create a new object.

Could be easily fixed in TYPO3\Fluid\ViewHelpers\Form\AbstractFormFieldViewHelper

currently:

    protected function getValue() {
        $value = NULL;

        if ($this->arguments->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();
        }
        if (is_object($value)) {
            $identifier = $this->persistenceManager->getIdentifierByObject($value);
            if ($identifier !== NULL) {
                $value = $identifier;
            }
        }
        return $value;
    }

Better:

    protected function getValue() {
        $value = NULL;

        if ($this->arguments->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();
        }
        if (is_object($value)) {
            $identifier = $this->persistenceManager->getIdentifierByObject($value);
            if ($identifier !== NULL) {
                $value = $identifier;
            }
        }
        return $value;
    }


Related issues

related to Core - Bug #59253: Additional Identity Properties not set on mapping error Resolved 2014-06-01
duplicated by TYPO3.Fluid - Bug #46038: Subproperty with Radio fields doesn't render hidden ident... Closed 2013-03-05
duplicated by TYPO3.Fluid - Bug #33274: Viewhelpers extending AbstractFormFieldViewHelper should ... Closed 2012-01-18

Associated revisions

Revision 3a56759e
Added by Alexander Berl almost 2 years ago

[BUGFIX] Additional Identity Properties not set on mapping error

When binding Fluid forms to nested objects, Fluid automatically adds
hidden fields with the identifiers of all affected objects so that
the persistence layer can update all objects correctly.

When a form was redisplayed due to property mapping errors, the
identity fields for the nested sub objects were no longer created.

This change fixes this by making sure all identity fields are rendered
recursively also after property mapping errors.

Example code to verify this::

<f:form action="update" object="{user}" objectName="user">
<f:form.textfield property="firstName" />
<f:for each="{user.invoices}" as="invoice" iteration="iteration"> {iteration.cycle}:
<f:form.textfield property="invoices.{iteration.index}.subject" />
</f:for>
<f:form.submit value="update" />
</f:form>

When submitting the form with validation errors, the redisplayed form
should contain a div with a hidden field named
"user[__identity]" for the user and one for each invoice.

Change-Id: I3debbc135d31278e91b83b3ac375bd5f62d13923
Fixes: #29290
Releases: master, 2.0

Revision 516fc370
Added by Alexander Berl almost 2 years ago

[BUGFIX] Additional Identity Properties not set on mapping error

When binding Fluid forms to nested objects, Fluid automatically adds
hidden fields with the identifiers of all affected objects so that
the persistence layer can update all objects correctly.

When a form was redisplayed due to property mapping errors, the
identity fields for the nested sub objects were no longer created.

This change fixes this by making sure all identity fields are rendered
recursively also after property mapping errors.

Example code to verify this::

<f:form action="update" object="{user}" objectName="user">
<f:form.textfield property="firstName" />
<f:for each="{user.invoices}" as="invoice" iteration="iteration"> {iteration.cycle}:
<f:form.textfield property="invoices.{iteration.index}.subject" />
</f:for>
<f:form.submit value="update" />
</f:form>

When submitting the form with validation errors, the redisplayed form
should contain a div with a hidden field named
"user[__identity]" for the user and one for each invoice.

Change-Id: I3debbc135d31278e91b83b3ac375bd5f62d13923
Fixes: #29290
Releases: master, 2.0

Revision b0740818
Added by Bastian Waidelich almost 2 years ago

[BUGFIX] Form ViewHelpers throw exception if no formObject is set

When using forms with object binding Fluid throws an exception for FormField
ViewHelpers bound to nested properties if no form object is available.
This is the case for example in newAction() where the object is usually NULL::

<f:form action="create" objectName="user">
<f:form.textfield property="name.firstName" />
</f:form>

Change-Id: I3b0af1667e45c9e5cbe56b5bca69d717ba206320
Related: #29290
Releases: master, 2.0

Revision 695cb813
Added by Bastian Waidelich over 1 year ago

[BUGFIX] Form ViewHelpers throw exception if no formObject is set

When using forms with object binding Fluid throws an exception for FormField
ViewHelpers bound to nested properties if no form object is available.
This is the case for example in newAction() where the object is usually NULL::

<f:form action="create" objectName="user">
<f:form.textfield property="name.firstName" />
</f:form>

Change-Id: I3b0af1667e45c9e5cbe56b5bca69d717ba206320
Related: #29290
Releases: master, 2.0

History

#1 Updated by Karsten Dambekalns almost 4 years ago

  • Affected Flow version set to FLOW3 1.0.0

#2 Updated by Bastian Waidelich over 3 years ago

  • Status changed from New to Accepted
  • Assigned To set to Bastian Waidelich

#3 Updated by Gerrit Code Review almost 3 years ago

  • Status changed from Accepted to Under Review

Patch set 1 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/13600

#4 Updated by Gerrit Code Review almost 3 years ago

Patch set 2 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/13600

#5 Updated by Gerrit Code Review almost 3 years ago

Patch set 3 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/13600

#6 Updated by Gerrit Code Review almost 3 years ago

Patch set 4 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/13600

#7 Updated by Gerrit Code Review over 2 years ago

Patch set 5 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/13600

#8 Updated by Gerrit Code Review over 2 years ago

Patch set 6 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/13600

#9 Updated by Gerrit Code Review over 2 years ago

Patch set 7 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/13600

#10 Updated by Gerrit Code Review almost 2 years ago

Patch set 8 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/13600

#11 Updated by Gerrit Code Review almost 2 years ago

Patch set 9 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/13600

#12 Updated by Gerrit Code Review almost 2 years ago

Patch set 10 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/13600

#13 Updated by Gerrit Code Review almost 2 years ago

Patch set 1 for branch 2.0 has been pushed to the review server.
It is available at https://review.typo3.org/24068

#14 Updated by Gerrit Code Review almost 2 years ago

Patch set 2 for branch 2.0 has been pushed to the review server.
It is available at https://review.typo3.org/24068

#15 Updated by Alexander Berl almost 2 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100

Also available in: Atom PDF