Bug #90734

inlineParentUid field is set to NULL in some cases when using FormInlineAjaxController

Added by Oliver Bartsch 27 days ago. Updated 6 days ago.

Status:
Closed
Priority:
Should have
Category:
FormEngine aka TCEforms
Target version:
-
Start date:
2020-03-11
Due date:
% Done:

100%

TYPO3 Version:
9
PHP Version:
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

Opening an inline record calls the /record/inline/details route which targets FormInlineAjaxController::detailAction().

There, the composed parentData might not hold the databaseRow which is used in FormInlineAjaxController::compileChild() to set the inlineParentUid.

This information is however needed for custom FromDataProvides to e.g. retrieve information of the parent record and use them as conditions to adjust the inline elements TCA or similar.

Associated revisions

Revision 61935dc3 (diff)
Added by Oliver Bartsch 8 days ago

[BUGFIX] Provide inlineParentUid in FormInlineAjaxController

By expanding an inline record the AJAX request calls the `detailAction`
in `FormInlineAjaxController`. The parent data array created in this
function does not contain the parent record's uid nor its database row.

In order to ensure that the uid is not NULL, in any FormDataProvider,
the uid is now added to the parent data array. This value is then used
as fallback in case there is no database row given in the `compileChild`
function which calls the FormDataProviders.

Resolves: #90734
Releases: master, 9.5
Change-Id: I66a4a20980d6c62a3e87496b6261b25f5e22aea6
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/63686
Tested-by: TYPO3com <>
Tested-by: Susanne Moog <>
Tested-by: Benni Mack <>
Reviewed-by: Christian Eßl <>
Reviewed-by: Susanne Moog <>
Reviewed-by: Benni Mack <>

Revision 64b406bc (diff)
Added by Oliver Bartsch 8 days ago

[BUGFIX] Provide inlineParentUid in FormInlineAjaxController

By expanding an inline record the AJAX request calls the `detailAction`
in `FormInlineAjaxController`. The parent data array created in this
function does not contain the parent record's uid nor its database row.

In order to ensure that the uid is not NULL, in any FormDataProvider,
the uid is now added to the parent data array. This value is then used
as fallback in case there is no database row given in the `compileChild`
function which calls the FormDataProviders.

Resolves: #90734
Releases: master, 9.5
Change-Id: I66a4a20980d6c62a3e87496b6261b25f5e22aea6
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/63976
Tested-by: TYPO3com <>
Tested-by: Benni Mack <>
Reviewed-by: Benni Mack <>

History

#1 Updated by Oliver Bartsch 27 days ago

  • Private changed from No to Yes

#2 Updated by Oliver Bartsch 27 days ago

After calling this->compileChild() there is the assignment $childData['inlineParentUid'] = (int)$parent['uid'] which is too late as the the compileChild() calls the FormDataCompiler::compile() inside without the inlineParentUid

#3 Updated by Oliver Bartsch 27 days ago

  • Private changed from Yes to No

Steps to reproduce (using styleguide extension)

  • Add a custom FormDataProvider (See example code below)
  • Create a new record (type: tx_styleguide_inline_1n)
  • Add an inline element (tx_styleguide_inline_1n_child)
  • Save record
  • Open the inline element by clicking on it (The inline element must be collapsed when the FormEngine loads)
  • Debug the $result['inlineParentUid'] in your custom FormDataProvider -> It is NULL

Example code:

// Register fromDataProvider in ext_localconf.php

$GLOBALS['TYPO3_CONF_VARS']['SYS']['formEngine']['formDataGroup']['tcaDatabaseRecord'][\TYPO3\CMS\Styleguide\Backend\Form\FormDataProvider\ProcessInline::class] =
    [
        'depends' => [
            \TYPO3\CMS\Backend\Form\FormDataProvider\TcaInline::class
        ]
    ];
// Create FormDataProvider in EXT:styleguide/Classes/Backend/Form/FormDataProvider/ProcessInline.php

<?php
declare(strict_types=1);

namespace TYPO3\CMS\Styleguide\Backend\Form\FormDataProvider;

use TYPO3\CMS\Backend\Form\FormDataProviderInterface;

class ProcessInline implements FormDataProviderInterface
{

    /**
     * @param array $result
     *
     * @return array
     */
    public function addData(array $result): array
    {
        // Debug $result['inlineParentUid'] here

        return $result;
    }
}

#4 Updated by Gerrit Code Review 27 days ago

  • Status changed from New to Under Review

Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/63686

#5 Updated by Gerrit Code Review 27 days ago

Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/63686

#6 Updated by Gerrit Code Review 27 days ago

Patch set 3 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/63686

#7 Updated by Gerrit Code Review 27 days ago

Patch set 4 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/63686

#8 Updated by Gerrit Code Review 8 days ago

Patch set 1 for branch 9.5 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/63976

#9 Updated by Oliver Bartsch 8 days ago

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

#10 Updated by Benni Mack 6 days ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF