Bug #84265
closedrecord pid invalid when using a Userfunction as TCA displayCond
0%
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.
Updated by Patrick Broens over 6 years ago
- 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.
Updated by Christian Kuhn almost 6 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.