Project

General

Profile

Actions

Bug #84232

closed

How to use ###PAGE_TSCONFIG_UID### with the fieldControls's "addRecord" in TCA?

Added by Gone With the Wind over 6 years ago. Updated over 5 years ago.

Status:
Closed
Priority:
Must have
Assignee:
-
Category:
Documentation
Start date:
2018-03-13
Due date:
% Done:

0%

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

Description

Neither the core nor the documentation (and so far my google search would lead me to even say: not even Google) offer a good example on how to use markers with "addRecord" in the TCA.

The situation is the following:

Each of the 2 tables - be it "category" and "book" - have a field, that relate to each other via m:m. The objects themselves have their own storagePid (and therefore folder page), where they store their data. "Category" as well as "Book" display their m:m-relation as a "selectMultipleSideBySide" select field, by which the records form "the other side" can be managed.

It makes sense to add an "addRecord" button to the fieldControl parameter, so I can add a "category" record, when I am in the "Book" form and vice versa. In order to save the record "from the other side" to its proper storagePid (folder page), the TCA requires the use of a marker like ###PAGE_TSCONFIG_UID###. The documentation does not clearly explain, how this is done, and so far it does not seem to work.

Documentation on "addRecord" within a "multipleSideBySide" renderType:
https://docs.typo3.org/typo3cms/TCAReference/ColumnsConfig/Type/Select.html#addrecord

As soon as "addRecord.pid" gets assign a hardcoded value, everything works as expected - with the very disturbing side effect that, upon saving, any and every data that was already selected, will be removed. This will be an extra entry, as soon as I get the markers working.


Related issues 1 (0 open1 closed)

Related to TYPO3 Core - Bug #84208: TCA: using addRecord in a selectMultipleSideBySide select field overwrites existing dataClosed2018-03-12

Actions
Actions #1

Updated by Gone With the Wind over 6 years ago

EDIT:

in Form/FormDataProvider/TcaFlexProcess there is a comment on line 366ff saying this:

// It is possible to have a flex field field with of foreign_table (eg. type=select) that has markers in
// a foreign_table_where like ###PAGE_TSCONFIG_ID###. It was possible to set this in page TSConfig for flex fields like this:
// TCEFORM.theTable.theFlexfield.PAGE_TSCONFIG_ID = 42
// This hands over this PAGE_TSCONFIG_ID to all flex fields that have this foreign_table_where marker.
// This is a contradiction to the "usual" page TSConfig flex configuration that should be done for single flex fields:
// TCEFORM.theTable.theFlexfield.theDataStructure.theSheet.theField.PAGE_TSCONFIG_ID = 42
// The below code is a hack to still simulate the old behavior that is now deprecated.
// @deprecated since TYPO3 v8, will be removed in TYPO3 v9
// When deleting this code and comment block, the according code within AbstractItemProvider can be removed, too.

But first of all this is for flex forms and second there is not description of a "new way".

Actions #2

Updated by Gone With the Wind over 6 years ago

EDIT 2:
"TCAdefaults.[table].pid = XY" does not work in this case, either.

Actions #3

Updated by Josef Glatz over 6 years ago

Hey Robert, your title says "###PAGE_TSCONFIG_UID###" – the U is not correct here. Maybe it's just a typo why it's not working?

Anyway.. I know not very much about the topic but maybe you find some useful stuff on github with this search? https://github.com/search?l=PHP&q=PAGE_TSCONFIG_ID&type=Code&utf8=%E2%9C%93

Actions #4

Updated by Gone With the Wind over 6 years ago

Hi, Josef, thanks for your comments, the search list is really useful!
The "u" is just a typo since I typed from memory, not copy-paste.

Most of the scripts that can be found use the markers in connection with the foreign_table_where param, but I need a solution for TYPO3 8 and "addRecord". The old wizard used to work perfectly fine, but the new one that came with the formEngine, removed some of that functionality and changed other parts (like overwriting the whole list, once the added record is saved - which is ... NOT GOOD!!!)

Actions #5

Updated by Benni Mack over 5 years ago

  • Target version changed from next-patchlevel to Candidate for patchlevel
Actions #6

Updated by Gone With the Wind over 5 years ago

  • Related to Bug #84208: TCA: using addRecord in a selectMultipleSideBySide select field overwrites existing data added
Actions #8

Updated by Gone With the Wind over 5 years ago

This is actually working! Yeah!
But the documentation needs a good example, the currently provided text does not explain cleary, how this feature can be used. Will follow.

For reference purposes here some code:

// TSconfig

[applicationContext = Development]

TCEFORM {
  tx_rwfm_domain_model_address {
    categories.PAGE_TSCONFIG_ID = 19
    locations.PAGE_TSCONFIG_ID = 4
    persons.PAGE_TSCONFIG_ID = 9
  }
  tx_rwfm_domain_model_addresscategory {
    addresses.PAGE_TSCONFIG_ID = 3
  }
}

[global]

// TCA

return [
  'columns' => [
    'addresses' => [
      'config' => [
        'addRecord' => [
          'pid' => '###PAGE_TSCONFIG_ID###'
        ]
      ]
    ]
  ]
]
Remarks:
  • the "pid" is the id of the child page that is referenced through the mm-field, here: categories or addresses respectively. The 'pid' of the parent table is completely irrelevant (this is, where the docu is most confusing IMO).
  • on trying several condition scenarios, it turns out that "hostname" will not work, "applicationContext" does.
Actions #9

Updated by Benni Mack over 5 years ago

  • Status changed from New to Closed

Issue closed on behalf of the Robert Wildling and Daniel Siepmann. Documentation will be updated accordingly.

Actions

Also available in: Atom PDF