[TYPO3-english] Flexform questions

Robert Wildling robertwildling at gmail.com
Tue May 8 10:33:07 CEST 2012


Please, I need your help:

For the displayCond part in a flexform I use the folloing script in the 
itemProcFunc:

<?php
class tx_rwhandselectedcontent_addFieldsToFlexForm
{
     function addFields ($config)
     {		
       	$piValues  = t3lib_div::xml2array($config['row']['pi_flexform']);
       	
       	// Werte in Variablen zwischenspeichern
       	$teaserPID = $piValues['data']['sDEF']['lDEF']['teaserPID']['vDEF'];
       	$col 	   = $piValues['data']['sDEF']['lDEF']['col']['vDEF'];
       	
       	// Prepare SQL Statement to get all child pages of current page
       	$queryParts['SELECT'] = '*';
       	$queryParts['FROM'] = 'tt_content';
       	$queryParts['WHERE'] = "pid=" . $teaserPID . ' AND colPos=' . $col;
       	$queryParts['GROUPBY'] = '';
       	$queryParts['SORTING'] = 'crdate';
       	$queryParts['LIMIT'] = '';
       	
       	$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
       		$queryParts['SELECT'],
       		$queryParts['FROM'],
       		$queryParts['WHERE'],
       		$queryParts['GROUPBY'],
       		$queryParts['SORTING'],
       		$queryParts['LIMIT']
       	);

       	$optionList = array();
       	$optionList[0] = array("Please choose...",0);
       	$i=1;
       	
       	while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
       		$optionList[$i] .= array($row['header'], $row['uid']);
       		$i++;
       	}

       	$GLOBALS['TYPO3_DB']->sql_free_result($res);

       	//debug($config,'configItems',__LINE__, __FILE__,5);
       	$config['items'] = array_merge($config['items'],$optionList);
		return $config;
     }
}
?>


The result is:
Please choose...
A
A


If I exchange the script according to this source:
http://wiki.typo3.org/wiki/Extension_Development,_using_Flexforms#Dynamic_Data_in_Flexforms

everything works fine - it is just not dynamic.

What is wrong here?
And where can I please find any documention about what to return to a 
select field in a flexform? Or an input field or any other field? I just 
don't know why this return value has to look as it looks now...

Furthermore: on debugging anything (like debug($config,'config')) every 
debug result is generated twice... as if there was a loop over two 
items, but there isn't... ???


This is the FF as it is written in the flexform_ds.xml:

<T3DataStructure>
	<meta>
		<langDisable>1</langDisable>
	</meta>
<sheets>
	<sDEF>
	<ROOT>
		<TCEforms>
		 
<sheetTitle>LLL:EXT:rwhandselectedcontent/locallang_tca.xml:title</sheetTitle>
		</TCEforms>
		<type>array</type>
		<el>
		
		<teaserPID>
			<TCEforms>
				<onChange>reload</onChange>
				<label>LLL:EXT:rwhandselectedcontent/locallang_tca.xml:teaserPID</label>
				<config>
					<type>input</type>
					<size>8</size>
					<max>8</max>
					<eval>trim</eval>
				</config>
			</TCEforms>
		</teaserPID>


	
		<infoOne>
			<TCEforms>
				<displayCond>FIELD:teaserPID:IN:0,NULL,''</displayCond>
				<label>LLL:EXT:rwhandselectedcontent/locallang_tca.xml:infoOne</label>
			</TCEforms>
		</infoOne>
	
	
		
		<col>
			<TCEforms>
				<displayCond>FIELD:teaserPID:!IN:0,NULL</displayCond>
				<label>LLL:EXT:rwhandselectedcontent/locallang_tca.xml:col</label>
				<config>
					<type>input</type>
					<size>8</size>
					<max>8</max>
					<eval>trim</eval>
					<autoSizeMax>10</autoSizeMax>
					<itemListStyle>width:250px</itemListStyle>
				</config>
			</TCEforms>
		</col>



		<infoTwo>
			<TCEforms>
				<displayCond>FIELD:col:=:0</displayCond>
				<label>LLL:EXT:rwhandselectedcontent/locallang_tca.xml:infoTwo</label>
			</TCEforms>
		</infoTwo>


	
		<contents>
			<TCEforms>
				<displayCond>FIELD:col:!=:0</displayCond>
				<label>LLL:EXT:rwhandselectedcontent/locallang_tca.xml:contents</label>
				<config>
					<type>select</type>
					<multiple>1</multiple>
					<maxitems>9</maxitems>
					<autosizemax>10</autosizemax>
					<!-- Commenting out these values makes no difference...
					<selectedListStyle>width:250px</selectedListStyle>
				    <itemListStyle>width:250px</itemListStyle>				    		
			        <items type="array"></items>
			        <allownonidvalues>1</allownonidvalues>
			        -->
				 
<itemsProcFunc>tx_rwhandselectedcontent_addFieldsToFlexForm->addFields</itemsProcFunc>
				</config>
			</TCEforms>
		</contents>


		</el>
	</ROOT>
</sDEF>
</sheets>
</T3DataStructure>



...and this is the Flexform as it is saved in the DB:

<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<T3FlexForms>
     <data>
         <sheet index="sDEF">
             <language index="lDEF">
                 <field index="teaserPID">
                     <value index="vDEF">405</value>
                 </field>
                 <field index="col">
                     <value index="vDEF">2</value>
                 </field>
                 <field index="contents">
                     <value index="vDEF"></value>
                 </field>
             </language>
         </sheet>
     </data>
</T3FlexForms>


Help please! I am stuck!

Thanks!
Robert


More information about the TYPO3-english mailing list