[TYPO3-english] Flexform questions

Jigal van Hemert jigal.van.hemert at typo3.org
Wed May 9 07:11:53 CEST 2012


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']);

-- 
Jigal van Hemert
TYPO3 Core Team member

TYPO3 .... inspiring people to share!
Get involved: typo3.org


More information about the TYPO3-english mailing list