--- t3lib/class.t3lib_tceforms.php~svn 2013-05-24 16:39:41.000000000 +0200 +++ t3lib/class.t3lib_tceforms.php~forge-50787 2013-08-09 18:02:04.000000000 +0200 @@ -1414,12 +1414,42 @@ $specConf = $this->getSpecConfFromString($PA['extra'], $PA['fieldConf']['defaultExtras']); // Getting the selector box items from the system - $selItems = $this->addSelectOptionsToItemArray( - $this->initItemArray($PA['fieldConf']), - $PA['fieldConf'], - $this->setTSconfig($table, $row), - $field - ); + + // Patch to implement FlexForms being accessible using _THIS_ROW (f.e. ###REC_FIELD_ in foreign_table_where) + // Gabriel Kaufmann + + $TSconfig = $this->setTSconfig($table, $row); + if($this->dataStructParent=='flex') { + // Parse FlexForm-Data to one-dimensional Array + $lDEF = 'lDEF'; + if( + $GLOBALS['TSFE']->config['config']['sys_language_uid']>0 && + !empty($GLOBALS['TSFE']->config['config']['language']) + ) { + $lDEF = strtoupper($GLOBALS['TSFE']->config['config']['language']); + } + + $flexArr = null; + if( ($flexArr = t3lib_div::xml2array($row[ $field ])) ) { + $flexArr = current($flexArr['data']); + $flexArr = isset($flexArr[ $lDEF ]) ? $flexArr[ $lDEF ] : $flexArr['lDEF']; + foreach($flexArr as $k => $v) { + $TSconfig['_THIS_ROW'][ $field.'.'.$k ] = current($v); + } + } + + if($config['type']=='select' || $config['group']) { + $TSconfig['_THIS_ROW'][ $field.'.'.$k ] = current(t3lib_div::trimExplode('|', $TSconfig['_THIS_ROW'][ $field.'.'.$k ], 1)); + } + } + + $selItems = $this->addSelectOptionsToItemArray( + $this->initItemArray($PA['fieldConf']), + $PA['fieldConf'], + $TSconfig, + $field + ); + // Possibly filter some items: $keepItemsFunc = create_function('$value', 'return $value[1];'); $selItems = t3lib_div::keepItemsInArray($selItems, $PA['fieldTSConfig']['keepItems'], $keepItemsFunc); @@ -2685,6 +2715,11 @@ // Data Structure array must be ... and array of course... if (is_array($dataStruct)) { + + // Set this flag to let sub-processing know if we are in FlexForm-processing + // Gabriel Kaufmann + $this->dataStructParent = 'flex'; + foreach ($dataStruct as $key => $value) { // Traversing fields in structure: if (is_array($value)) { // The value of each entry must be an array. @@ -2986,6 +3021,9 @@ } } } + // Reset flag after leaving FlexForm-processing + // Gabriel Kaufmann + $this->dataStructParent = ''; return $output; }