Project

General

Profile

Actions

Bug #46477

closed

IRRE shows no field values with useCombination

Added by Stefan Froemken about 11 years ago. Updated over 6 years ago.

Status:
Closed
Priority:
Should have
Assignee:
Category:
FormEngine aka TCEforms
Target version:
Start date:
2013-03-20
Due date:
% Done:

100%

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

Description

Hello Core-Team,

I have implemented an irre field with an intermediate table. Let's say I have Events with a Location.
In table "event" I have a field "location" configured with foreign_selector, foreign_unique and useCombination. First of all I wonder: Where is the red color? In my opinion all fields have a red border when I configure an irre field that way. OK...maybe you have changed this within the last year.

I select a new entry from selectbox (foreign_selector) and after saving everything seems to be good. So I create a new entry (add new (useCombination)) but after saving my previous selected entry has no values anymore. My newly created entry seems to be OK.

I have inspected one of the empty fields:

<span class="t3-tceforms-input-wrapper" onmouseover="if (document.getElementById('tceforms-textfield-514a161d7288a').value) {this.className='t3-tceforms-input-wrapper-hover';} else {this.className='t3-tceforms-input-wrapper';};" onmouseout="this.className='t3-tceforms-input-wrapper';"><span tag="a" class="t3-icon t3-icon-actions t3-icon-actions-input t3-icon-input-clear t3-tceforms-input-clearer" onclick="document.getElementById('tceforms-textfield-514a161d7288a').value='';document.getElementById('tceforms-textfield-514a161d7288a').focus();typo3form.fieldGet('data[tx_events2_domain_model_location][2][location]','trim','',1,'');TBE_EDITOR.fieldChanged('tx_events2_domain_model_location','2','location','data[tx_events2_domain_model_location][2][location]');">&nbsp;</span><input type="text" id="tceforms-textfield-514a161d7288a" class="formField1 tceforms-textfield hasDefaultValue" name="data[tx_events2_domain_model_location][2][location]_hr" value="" style="width: 288px; " maxlength="256" onchange="typo3form.fieldGet('data[tx_events2_domain_model_location][2][location]','trim','',1,'');TBE_EDITOR.fieldChanged('tx_events2_domain_model_location','2','location','data[tx_events2_domain_model_location][2][location]');"><input type="hidden" name="data[tx_events2_domain_model_location][2][location]" value="Haus Dahl"></span>

As you can see, the value "Haus Dahl" was found, but I can't see this value in the field!
I have tested it on two different TYPO3-Systems using 4.7.10.

Any ideas?

Stefan


Files

T3X_sftestirre--z-201303271355.t3x (98.3 KB) T3X_sftestirre--z-201303271355.t3x Stefan Froemken, 2013-03-27 14:02
Actions #1

Updated by Stefan Froemken about 11 years ago

Here is the field "location" of my table "events":

'location' => array(
    'exclude' => 0,
    'label' => 'LLL:EXT:events2/Resources/Private/Language/locallang_db.xlf:tx_events2_domain_model_event.location',
    'config' => array(
        'type' => 'inline',
        'foreign_table' => 'tx_events2_event_location_mm',
        'foreign_field' => 'event_uid',
        'foreign_selector' => 'location_uid',
        'foreign_unique' => 'location_uid',
        'foreign_sortby' => 'event_sort',
        'maxitems' => 99,
        'appearance' => array(
            'useCombination' => 1,
        ),
    ),
),

Here the TCA for my MM-Table:

'event_uid' => array(
    'label' => 'Event UID',
    'config' => array(
        'type' => 'select',
        'foreign_table' => 'tx_events2_domain_model_event',
        'size' => 1,
        'minitems' => 1,
        'maxitems' => 1,
    ),
),
'location_uid' => array(
    'label' => 'Location UID',
    'config' => array(
        'type' => 'select',
        'foreign_table' => 'tx_events2_domain_model_location',
        'size' => 1,
        'minitems' => 1,
        'maxitems' => 1,
    ),
),
'event_sort' => array(
    'config' => array(
        'type' => 'passthrough',
    ),
),

At last the field "event" of table "location":

'event' => array(
    'config' => array(
        'type' => 'passthrough',
    ),
),
Actions #2

Updated by Stefan Froemken about 11 years ago

Very funny,

if I collapse alle irre elements and save the record and unfold them again all values are empty

If I unfold the irre elements and save the record all fields are filled correctly.

Stefan

Actions #3

Updated by Stefan Froemken about 11 years ago

In jsfunc.inline.js you have following:

var selectedValue = recordObj[0].options[recordObj[0].selectedIndex].value;

But in my case this input-field is not of type select. So it does not have any options to remove.
Because of this error all following JS-Code was not executed. This foreach breaks:

if (json.scriptCall && json.scriptCall.length) {
    $A(json.scriptCall).each(function(value) { console.log(value); eval(value); });
}

I have replaced your code with following:

if (recordObj.length) {
    if (recordObj[0].hasOwnProperty('options')) {
        var selectedValue = recordObj[0].options[recordObj[0].selectedIndex].value;
        for (var i=0; i<values.length; i++) {
            if (values[i] != selectedValue) {
                this.removeSelectOption(recordObj[0], values[i]);
            }
        }
    }
}

Now it works.

Stefan

Actions #4

Updated by Stefan Froemken about 11 years ago

Since TYPO3 4.3 you have following in class.t3lib_tceforms_inline.php

if ($isNewRecord) {
    $comboFormFieldName = $this->prependFormFieldNames.'['.$comboConfig['foreign_table'].']['.$comboRecord['uid'].'][pid]';
    $out .= '<input type="hidden" name="'.$comboFormFieldName.'" value="'.$comboRecord['pid'].'" />';
}
if ($isNewRecord || $config['foreign_unique'] == $foreign_selector) {
    $parentFormFieldName = $this->prependFormFieldNames.$appendFormFieldNames.'['.$foreign_selector.']';
    $out .= '<input type="hidden" name="'.$parentFormFieldName.'" value="'.$comboRecord['uid'].'" />';
}

Here you can see that this field has never been a select field. So this line in jsfunc.inline.js must be basically wrong:

var selectedValue = recordObj[0].options[recordObj[0].selectedIndex].value;

Stefan

Actions #5

Updated by Gerrit Code Review about 11 years ago

  • Status changed from New to Under Review

Patch set 1 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/19337

Actions #6

Updated by Oliver Hader about 11 years ago

Can you provide a simple extract of your extension to actually test it?

Actions #7

Updated by Stefan Froemken about 11 years ago

Hi Oliver,

I have attached a little test extension with extension_builder. Create 2 or more locations first. Then jump into an event and select a location from selectbox. The new Element appears and values are filled. Close this IRRE-Element (collapse) and save this record and let it show again in same window.Now IRRE-Element should be collapsed. Try opening it and you will see that the value of location is lost.

Stefan

Actions #8

Updated by Stanislas Rolland almost 11 years ago

  • TYPO3 Version changed from 4.7 to 4.5

I encountered the same issue with TYPO3 4.5.25.

The proposed change does fix the issue.

Actions #9

Updated by Johannes Kropf over 10 years ago

I encountered the same issue with TYPO3 4.7.17 and 6.1

Please fix.

Regards,

Johannes

Actions #10

Updated by Lorenz Ulrich over 10 years ago

The change works and solves the problem, thanks. Let's hope it will be considered when the JS is refactored.

Actions #11

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/19337

Actions #12

Updated by Lorenz Ulrich almost 10 years ago

I just rebase this for 6.2 and reworked the commit message.

A real-life demo is the 6.2 fork of "html5videoplayer":
https://github.com/visol/html5videoplayer

Steps to reproduce:

  1. Add at least two videos in a folder and add e.g. its YouTube URL
  2. Add a video player CE and add one of the videos.
  3. On expanding the video relation you will see the correct title and URL of the video.
  4. Save and close the CE.
  5. Reopen the CE and expand the video relation again: The fields will be empty and you will have an error in the JavaScript console.

After applying the patch (and clearing JS caches), it works.

Actions #13

Updated by Stefan Froemken almost 10 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100
Actions #14

Updated by Riccardo De Contardi over 6 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF