[TYPO3-english] Flexform questions

Robert Wildling robertwildling at gmail.com
Wed May 9 11:18:24 CEST 2012


Jigal - thank you VERY VERY MUCH!!! In general, my little scripts now 
works and thanks to your explanations I can read and understand the 
documentation better! Again: THANK YOU!!

Could you maybe help me understand the following behaviour?

When the debugging statement after the loop is commented out:

...
	while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
       		$config['items'][] = array(0=>$row['header'], 1=>$row['uid']);
       		$i++;
       	}
-->   	debug($config['items'],'configItems',__LINE__, __FILE__,5);
	return $config;
...


the debug page contains twice the same result. This does NOT happen, 
when only the first field is filled in in the flexform (which indicated 
the Page ID). But as soon as the second field (the column indicator) 
appears (ONLy appears, not even has a value), the debugger throughs 2x 
the same result.

The behaviour is the same, no matter how many more field I add to the 
Felxform...

Is this an expected behaviour? If so, why?


Thank you!
Regards,
Robert



> Hi,
>
> On 8-5-2012 23:56, Robert Wildling wrote:
>> I do have a script, but the return values are wrong - and I don't why.
>> The debug statements through the correct contents, but obviousely I am
>> putting them together in a wrong way... the multiselect result list is
>> filled with these 3 values:
>>
>> Please choose...
>> A
>> A
>>
>> I Have absolutely no idea where the 2 "A"s come from...???
> [...]
>> $optionList[$i] .= array(0=>$row['header'], 1=>$row['uid']); // <-- here
>> sth is wrong!!!
>
> The .= operator is a string operator, so it will treat the right side
> argument as a string. The right side argument is an array and when cast
> to a string it will result in "Array".
> $optionList[$i] is now a string with the value "Array".
>
> TYPO3 expects the items in the list to be arrays with two elements, the
> first being the label, the second the value. It will probably just do
> $item[0] to get the label. If you do this on a string it will result in
> the first character and just display "A".
>
> Now for the solution. The $config array is passed as a reference which
> makes it possible to directly write to it without using the intermediate
> $optionList array.
>
> In the while loop just use:
> $config['items'][] = array($row['header'], $row['uid']);
>



More information about the TYPO3-english mailing list