Fixed bug: #5098: IRRE - foreign_unique without foreign_selector doesn't work
authorOliver Hader <oliver.hader@typo3.org>
Sun, 4 Mar 2007 12:07:30 +0000 (12:07 +0000)
committerOliver Hader <oliver.hader@typo3.org>
Sun, 4 Mar 2007 12:07:30 +0000 (12:07 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@2169 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
t3lib/class.t3lib_tceforms_inline.php

index 38c6fe2..3935e6e 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2007-03-04  Oliver Hader  <oh@inpublica.de>
+
+       * Fixed bug: #5098: IRRE - foreign_unique without foreign_selector doesn't work
+
 2007-03-01  Oliver Hader  <oh@inpublica.de>
 
        * Fixed bug: #5069: TSconfig mod.web_list.allowedNewTables used in t3lib_TCEforms_inline
index 3b7b415..b2149d4 100755 (executable)
@@ -193,7 +193,7 @@ class t3lib_TCEforms_inline {
 
                        // if relations are required to be unique, get the uids that have already been used on the foreign side of the relation
                if ($config['foreign_unique']) {
-                               // If unique *and* selector, the should both be the same - get config:
+                               // If uniqueness *and* selector are set, they should point to the same field - so, get the configuration of one:
                        $selConfig = $this->getPossibleRecordsSelectorConfig($config, $config['foreign_unique']);
                                // Get the used unique ids:
                        $uniqueIds = $this->getUniqueIds($recordList, $config, $selConfig['type']=='groupdb');
@@ -206,7 +206,7 @@ class t3lib_TCEforms_inline {
                                'table' => $config['foreign_table'],
                                'elTable' => $selConfig['table'], // element/record table (one step down in hierarchy)
                                'field' => $config['foreign_unique'],
-                               'selector' => $selConfig['PA'] && $selConfig['type'] ? $selConfig['type'] : false,
+                               'selector' => $selConfig['selector'],
                                'possible' => $this->getPossibleRecordsFlat($possibleRecords),
                        );
                }
@@ -1559,6 +1559,7 @@ class t3lib_TCEforms_inline {
                $PA = false;
                $type = false;
                $table = false;
+               $selector = false;
                
                if ($field) {
                        $PA = array();
@@ -1570,12 +1571,17 @@ class t3lib_TCEforms_inline {
                        $type = $this->getPossibleRecordsSelectorType($config);
                                // Return table on this level:
                        $table = $type == 'select' ? $config['foreign_table'] : $config['allowed'];
+                               // Return type of the selector if foreign_selector is defined and points to the same field as in $field:
+                       if ($foreign_selector && $foreign_selector == $field && $type) {
+                               $selector = $type;
+                       }
                }
                
                return array(
                        'PA' => $PA,
                        'type' => $type,
-                       'table' => $table
+                       'table' => $table,
+                       'selector' => $selector,
                );
        }