Project

General

Profile

Actions

Bug #84265

closed

record pid invalid when using a Userfunction as TCA displayCond

Added by Marcel Macasso over 6 years ago. Updated about 6 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
-
Target version:
-
Start date:
2018-03-14
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
8
PHP Version:
7.0
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

Depending on the pid of a new created record I want to hide or show a field. This works when I click in the page tree on the sys folder and then create in the list view a new element. The record pid in my userfunction is set, and contains the correct one. If I then use the dropdown and click on "Save and create a new one", then the record pid is set to '-9'. Now my condition is not working, and the field is not shown. After I press "Save", my field is there, because the pid is set.

TCA:

'fieldname' => [
            'displayCond' => 'USER:Vendor\\Extensionname\\User\\TcaUserFunctions->displayIfCorrectPid',
            'exclude' => false,
            'label' => 'My label',
            'config' => [
                'type' => 'input',
                'size' => 16,
                'eval' => 'datetime,required'
            ]
        ]

Userfunction:

    /**
     * Checks if pid = 10
     *
     * @param array $configuration
     * @param \TYPO3\CMS\Backend\Form\FormDataProvider\EvaluateDisplayConditions $evaluateDisplayConditions
     * @return bool
     */
    public function displayIfCorrectPid(array $configuration, $evaluateDisplayConditions = null)
    {
        if($configuration['record']['pid'] == 10) {
            return true;
        }

        return false;
    }

Not 100% sure though if it is meant to be reading out the pid of the element in a condition like this.

Actions

Also available in: Atom PDF