Bug #80699

Story #69617: FormEngine bugs

Inline elements with foreign TCA relation to another table should load relations before saving record

Added by Thomas Hohn about 2 years ago. Updated about 1 year ago.

Status:
Accepted
Priority:
Should have
Assignee:
-
Category:
FormEngine aka TCEforms
Target version:
-
Start date:
2017-04-05
Due date:
% Done:

0%

TYPO3 Version:
4.5
PHP Version:
7.0
Tags:
Complexity:
Is Regression:
No
Sprint Focus:

Description

We have a BackendPage with some in-line elements and in the inline elements there is foreign TCA relation to another table.

When we create a new element (before saving it) we would like to be able to display the existing relations - but the
###REC_FIELD_questions_uid### of the new inline-element is empty making it impossible to use AND questions_uid=###REC_FIELD_questions_uid###
in the foreign_table_where.
This used to be the case in previous versions of TYPO3.

The problem seems to be in the processing of ###REC_FIELD_field_name### where an extra condition could be added in case that the
###REC_FIELD_field_name### matches the [inlineParentConfig][foreign_field] it could be assigned the value from $result['inlineParentUid']
which is present at that time.

Use-case:

Matching of source and targets elements on a BE form.
User typically creates a number of targets on the form which are store in tx_systimequizmatching_targets.
Now the user want's to create relations between sources and targets by creating a source element in the
same form.
Before the patch the ###REC_FIELD_questions_uid### can't be resolved before the form has been saved - which makes it cumbersome
to create a lot of relations since it requires "create source element", "save" , "go to element again", "create relations" and
"save".

The prober way (used to be so in previous versions of TYPO3) was create source element, add relation and save (faster).

Involved tables:

Table tx_systimequizmatching_sources (sources)
Table tx_systimequizmatching_targets (targets)
Table tx_systimequizmatching_sources_targets_mm (MM table)

TCA for part of tx_systimequizmatching_sources is

 'targets' => array(
            'exclude' => 0,
            'label' => 'LLL:EXT:systime_quiz_matching/Resources/Private/Language/locallang_db.xlf:tx_systimequizmatching_sources.targets',
            'config' => array(
                'type' => 'select',
                'renderType' => 'selectCheckBox',
                'disableNoMatchingValueElement' => 1,
                'foreign_table' => 'tx_systimequizmatching_targets',
                'foreign_table_where' => 'AND questions_uid=###REC_FIELD_questions_uid### AND questions_uid > 0 ORDER BY tx_systimequizmatching_targets.sorting',
                'size' => 10,
                'minitems' => 0,
                'maxitems' => 10,
                'MM' => 'tx_systimequizmatching_sources_targets_mm',
                'renderMode' => 'checkbox',
            )
        ),

Before-saving-record.png View - Before saving record (111 KB) Thomas Hohn, 2017-04-05 18:48

After-saving-record-expected-behaviour.png View - After save/Expected behaviour (109 KB) Thomas Hohn, 2017-04-05 18:48

History

#3 Updated by Thomas Hohn about 2 years ago

  • Description updated (diff)

#4 Updated by Thomas Hohn about 2 years ago

  • Description updated (diff)

#5 Updated by Thomas Hohn about 2 years ago

  • Description updated (diff)

#6 Updated by Oliver Hader about 2 years ago

  • Status changed from New to Needs Feedback

How does your TCA settings look like for the field containing the ###REC_FIELD_...### condition?
In general foreign_table_where should not be allowed for TCA type inline, but for type select see https://docs.typo3.org/typo3cms/TCAReference/7.6/Reference/Columns/Select/#foreign-table-where

#7 Updated by Oliver Hader about 2 years ago

  • Target version deleted (Candidate for patchlevel)

#8 Updated by Thomas Hohn about 2 years ago

The TCA looks like:

        ....
        'targets' => array(
            'exclude' => 0,
            'label' => 'LLL:EXT:systime_quiz_matching/Resources/Private/Language/locallang_db.xlf:tx_systimequizmatching_sources.targets',
            'config' => array(
                'type' => 'select',
                'renderType' => 'selectCheckBox',
                'disableNoMatchingValueElement' => 1,
                'foreign_table' => 'tx_systimequizmatching_targets',
                'foreign_table_where' => 'AND questions_uid=###REC_FIELD_questions_uid### AND questions_uid > 0 ORDER BY tx_systimequizmatching_targets.sorting',
                'size' => 10,
                'minitems' => 0,
                'maxitems' => 10,
                'MM' => 'tx_systimequizmatching_sources_targets_mm',
                'renderMode' => 'checkbox',
            )
        ),
       ...

It works fine - except when the in-line element is created since the questions_uid is then empty. There seems to be a comment
// @todo: Throw exception if there is no value? What happens for NEW records?

in the source code - could do the fix - maybe it's then more clear what the problem is?

#9 Updated by Gerrit Code Review about 2 years ago

  • Status changed from Needs Feedback 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/52371

#10 Updated by Gerrit Code Review about 2 years 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/52371

#11 Updated by Gerrit Code Review about 2 years 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/52371

#12 Updated by Gerrit Code Review about 2 years 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/52371

#13 Updated by Gerrit Code Review about 2 years ago

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

#14 Updated by Thomas Hohn about 2 years ago

  • Description updated (diff)

#15 Updated by Gerrit Code Review about 2 years ago

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

#16 Updated by Christian Kuhn about 2 years ago

  • Parent task set to #69617

#17 Updated by Susanne Moog over 1 year ago

  • Category set to FormEngine aka TCEforms

#18 Updated by Mona Muzaffar about 1 year ago

  • Status changed from Under Review to Accepted

Also available in: Atom PDF