Bug #30354
closedFlexForm select fields can't replace makers in their foreign_table_where clause
0%
Description
FlexForm select fields can't replace makers (like ###PAGE_TSCONFIG_IDLIST###) in their foreign_table_where clause in the left hand part of the input because the $field argument in selectAddForeign() is empty.
The righthand side part of the select field (taht lists all records) can convert these in to the correct values, the records are selectable and their uids are saved in the flexform in the tt_content record, but they are not shown in the left hand side where the actual selected records are shown.
Here is the flexform ds for my select field:
<category> <TCEforms> <label>LLL:EXT:sb_portfolio/pi1/flexform_locallang.xml:itemSelection.category</label> <config> <type>select</type> <items type="array"> <numIndex index="0" type="array"> <numIndex index="0">LLL:EXT:sb_portfolio/pi1/flexform_locallang.xml:itemSelection.category.0</numIndex> <numIndex index="1">-1</numIndex> </numIndex> <numIndex index="1" type="array"> <numIndex index="0">LLL:EXT:sb_portfolio/pi1/flexform_locallang.xml:itemSelection.category.1</numIndex> <numIndex index="1">--div--</numIndex> </numIndex> </items> <exclusiveKeys>-1</exclusiveKeys> <foreign_table_where> AND tx_sbportfolio_categories.pid IN (###STORAGE_PID###, ###PAGE_TSCONFIG_IDLIST###) AND (tx_sbportfolio_categories.sys_language_uid=0 || (tx_sbportfolio_categories.sys_language_uid>0 AND tx_sbportfolio_categories.l10n_parent=0)) ORDER BY tx_sbportfolio_categories.title ASC</foreign_table_where> <foreign_table>tx_sbportfolio_categories</foreign_table> <size>6</size> <autoSizeMax>12</autoSizeMax> <minitems>0</minitems> <maxitems>500</maxitems> </config> </TCEforms> </category>
i have solved it useing an itemsProcFunc that works just on the left hand part of the select field, but I believe this is a bug. If the righthand record list is able to convert these markers, and they are selectable, and saved in the DB, the the left part of the select field should be capable os shwoing them too. they are after all selected.
Without $field being set to 'pi_flexform' it can't as the field is needed in the function exec_foreign_table_where_query().
An example:
$fTWHERE = str_replace('###PAGE_TSCONFIG_IDLIST###', $GLOBALS['TYPO3_DB']->cleanIntList($TSconfig[$field]['PAGE_TSCONFIG_IDLIST']), $fTWHERE);
Files
Updated by Stephen Bungert over 13 years ago
Here is my itemsProcFunc function that I use to correctly show the selected records
Updated by Peter Niederlag over 13 years ago
- Status changed from New to Needs Feedback
- I assume the markers ###STORAGE_PID###, ###PAGE_TSCONFIG_IDLIST### are properly replaced by theire TSconfig values (mind that IMO you are in danger to end up with invalid SQL if one of them is not filled)?
- You can select items from the list?
- The items you have selected dont show up on saving, or not even after selecting?
- Do you have some special configuration/userFunc on generating the label?
- As you seem to make records with different sys_language.uid available, does that have any influence?
Updated by Stephen Bungert over 13 years ago
Hello Peter,
###PAGE_TSCONFIG_IDLIST### is replaced with the page tsconfig content for the right hand part of the select field. The select field's right input that shows all the records correctly and finds all the records because it can replace the markers in the foreign_table_where part of my FlexForm DS.
If I select any of the records they get saved in the db when I save the form, but upon reloading the left hand input that makes up the select element doesn't display the selected records that have PIDs = to those that I set in tsconfig with PAGE_TSCONFIG_IDLIST. The hard coded items in the items array and those records in the storage folder show up ok.
After debugging parts of TYPO3 when TYPO3 creates the form field I discovered that when creating the left input for the select field, the $field argument passed to selectAddForeign() is empty, and without $field being set to pi_flexform the str_replace call in exec_foreign_table_where_query() fails:
$fTWHERE = str_replace('###PAGE_TSCONFIG_IDLIST###', $GLOBALS['TYPO3_DB']->cleanIntList($TSconfig[$field]['PAGE_TSCONFIG_IDLIST']), $fTWHERE);
"(mind that IMO you are in danger to end up with invalid SQL if one of them is not filled)?"
No, no, it is ok. Storgae PID is always set and even if PAGE_TSCONFIG_IDLIST is not set in the tsconfig it becomes 0 in the sql clause.
I don't have any special function creating the label.
the thing with sys_language.uid doesn't effect this.
if I make the foreign_table_where clause this:
<foreign_table_where> AND (tx_sbportfolio_categories.sys_language_uid=0 || (tx_sbportfolio_categories.sys_language_uid>0 AND tx_sbportfolio_categories.l10n_parent=0)) ORDER BY tx_sbportfolio_categories.title ASC</foreign_table_where>
Then they selected records show up ok, even if they are not in the storage folder, but stored in the PIDs set in tsconfig.
THis is really just a problem with the left input field in the select field, because $field is empty, it can't convert the markers in exec_foreign_table_where_query().
Updated by Stephen Bungert over 13 years ago
Having looked a bitmore at this, I see in the function renderRecord_SW() in class.t3lib_transferdata.php that in the functions help declaration it mentions that $field is empty for flex forms.
/** * Function with the switch() construct which triggers functions for processing of the data value depending on the TCA-config field type. * * @param string Value to process * @param array TCA/columns array for field (independant of TCA for flexforms - coming from XML then) * @param array TSconfig (blank for flexforms for now) * @param string Table name * @param array The row array, always of the real record (also for flexforms) * @param string The field (empty for flexforms!) * @return string Modified $value */ function renderRecord_SW($data, $fieldConfig, $TSconfig, $table, $row, $field) {
I think this is the cause of the problem.
I believe this is a bug because the right hand part of the select field can convert these markers and any records that I select are saved ok in the flexform DS. It is just when the form reloads, or the record is first opened that the problem occurs.
It doesn't say why $field is empty for FF, why is this so? It's need to be set for any of the markers in exec_foreign_table_where_query() to be converted.
Updated by Stephen Bungert over 13 years ago
- File ffbug01.png ffbug01.png added
- File ffbug02.png ffbug02.png added
- File ffbug03.png ffbug03.png added
Here are some pics to show the problem, I can also post some while debugging TYPO3 during form rendering if you like to show you that $field is empty when the left hand input that makes up part of the flexform's select field is created.
Pic 01:
Here you can see that the right hand part of the field has found all the cats. The red marked category comes from the general record storage folder for the site. The ###STORAGE_PID### doesn't need $field to be set in order to get converted.
The green marked cats come from another sys_folder and this folder's PID is specified in TSCONFIG (###PAGE_TSCONFIG_IDLIST###). TYPO3 has, when creating the right hand input for the select field, converted all the markers and thus found all the categories.
You can see after selecting them that they appear ok in the left hand input too.
Pic 02
This what you see after saving or when opening the Content Element for the first time. Only the cats selected that are in the storage folder show up.
This should not be the case though because...
Pic 03:
...all 4 categories have had their IDs saved to the FlexForm DS for the field in it's tt_content record. You can see that all four categories have been selected ok and saved to the DB.
Updated by Michael Spitz over 12 years ago
Same Problem, but simpler Example:
<address>
<TCEforms>
<label>LLL:EXT:test/pi1/locallang.xml:tt_content.flexform.address</label>
<config>
<type>select</type>
<foreign_table>tt_address</foreign_table>
<foreign_table_where>AND tt_address.pid=###PAGE_TSCONFIG_ID### ORDER BY tt_address.name</foreign_table_where>
<size>4</size>
<minitems>1</minitems>
<maxitems>10</maxitems>
</config>
</TCEforms>
</address>
A simple Selectbox with maxitems=1 works fine, this problem only occurs on Multi-Select-Fields.
Updated by Lars Houmark over 12 years ago
I can confirm that this bug is still present in 4.7.5.
Updated by Kim Lang over 11 years ago
Lars Houmark wrote:
I can confirm that this bug is still present in 4.7.5.
I can confirm that this bug is still present in 6.1
Updated by Alexander Opitz over 11 years ago
- Status changed from Needs Feedback to New
Updated by Gabriel Kaufmann / Typoworx NewMedia over 11 years ago
May this bug/feature request may have to do with my issue #50785 regarding using "REC_FIELD_"-Markers for accessing FlexForm-Values within foreign_table_where?
Updated by Stephen Bungert over 11 years ago
I think so... I fixed the problem by using, itemsProcFunc. Maybe you can use it and modify it to your needs.
Updated by Stefan Isak over 11 years ago
I can confirm this behaviour is still the same in TYPO3 6.1.3. Saving the form leads to lost record relations.
In my case it's exactly the same thing Stephen Bungert described. I also consider it as a bug.
Updated by Sergio Catalá over 10 years ago
I confirm this behaviour happens in 6.2.1 too.
Updated by Gerrit Code Review over 10 years ago
- Status changed from New 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/30781
Updated by Gerrit Code Review over 10 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/30781
Updated by Wouter Wolters over 10 years ago
- Status changed from Under Review to Resolved
- Is Regression set to No
Resolved with #16392