Project

General

Profile

Actions

Bug #84265

closed

record pid invalid when using a Userfunction as TCA displayCond

Added by Marcel Macasso about 6 years ago. Updated over 5 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 #1

Updated by Patrick Broens about 6 years ago

The name of the "pid" value is a bit misleading. When adding content in the "Page" module, this value depends if you are clicking:
  • the first "+Content" button, above all content elements
  • a "+Content" button below an already existing content element

For the first situation this is the pid of the page as positive integer.
For the second one it is a negative integer of the uid of the content element above the button you've clicked.

In case the integer is negative, you first need to fetch the pid of the content element.

Actions #2

Updated by Christian Kuhn over 5 years ago

  • Status changed from New to Closed

Yes. Display condition user functions unfortunately only receive the record array, but not the full "result" array from the data providers. The 'pid' of the record thus can have 'NEW...' in it, or can be negative if the record is added 'below' another one. This is ... well ... by design, and your code has to cope with that somehow.

Actions

Also available in: Atom PDF