Project

General

Profile

Actions

Bug #30354

closed

FlexForm select fields can't replace makers in their foreign_table_where clause

Added by Stephen Bungert over 12 years ago. Updated over 5 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
-
Target version:
-
Start date:
2011-09-27
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
4.5
PHP Version:
Tags:
Complexity:
Is Regression:
No
Sprint Focus:

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

class.tx_sbportfolio_ffcategories.zip (1.72 KB) class.tx_sbportfolio_ffcategories.zip itemsProcFunc to fix problem Stephen Bungert, 2011-09-27 15:03
ffbug01.png (43.3 KB) ffbug01.png Stephen Bungert, 2011-09-30 22:58
ffbug02.png (42.6 KB) ffbug02.png Stephen Bungert, 2011-09-30 22:58
ffbug03.png (22.4 KB) ffbug03.png Stephen Bungert, 2011-09-30 22:58

Related issues 2 (0 open2 closed)

Related to TYPO3 Core - Bug #50785: FlexForm does not substitute markers in foreign_table_whereClosed2013-08-05

Actions
Related to TYPO3 Core - Bug #16392: Page-TSconfig ###PAGE_TSCONFIG_STR### not evaluated correctly in BackendClosed2006-07-21

Actions
Actions #1

Updated by Stephen Bungert over 12 years ago

Here is my itemsProcFunc function that I use to correctly show the selected records

Actions #2

Updated by Peter Niederlag over 12 years ago

  • Status changed from New to Needs Feedback
Sry, I don't exactly understand the problem. Could you please be more elaborate? attach a screenshot? the full extension?
  • 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?
Actions #3

Updated by Stephen Bungert over 12 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().

Actions #4

Updated by Stephen Bungert over 12 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 12 years ago

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.

Actions #6

Updated by Michael Spitz almost 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.

Actions #7

Updated by Lars Houmark over 11 years ago

I can confirm that this bug is still present in 4.7.5.

Actions #8

Updated by Kim Lang almost 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

Actions #9

Updated by Alexander Opitz almost 11 years ago

  • Status changed from Needs Feedback to New
Actions #10

Updated by Gabriel Kaufmann / Typoworx NewMedia over 10 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?

Actions #11

Updated by Stephen Bungert over 10 years ago

I think so... I fixed the problem by using, itemsProcFunc. Maybe you can use it and modify it to your needs.

Actions #12

Updated by Stefan Isak over 10 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.

Actions #13

Updated by Sergio Catalá almost 10 years ago

I confirm this behaviour happens in 6.2.1 too.

Actions #14

Updated by Gerrit Code Review almost 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

Actions #15

Updated by Gerrit Code Review almost 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

Actions #16

Updated by Wouter Wolters almost 10 years ago

  • Status changed from Under Review to Resolved
  • Is Regression set to No

Resolved with #16392

Actions #17

Updated by Benni Mack over 5 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF