[TYPO3-mvc] Select-field with items-array and foreign_table

Jochen Rau jochen.rau at typoplanet.de
Tue Jan 26 11:08:06 CET 2010


Hi Stefan.

I stumbled upon your unreplied post.

On 05.01.10 11:06, Stefan Geith wrote:
> First of all: "A Happy New Year to All of You!"

Happy new year! ;-)

> Situation:
> I have an article- and a categories-Table (and model).
> TCA for the category-field in articles looks like this:
> 'category' => array (
> 'label' => 'category',
> 'config' => array (
> 'type' => 'select',
> 'items' => Array (
> Array('',0),
> ),
> 'foreign_table' => 'tx_myext_domain_model_category',
> 'foreign_class' => 'Tx_MyExt_Domain_Model_Category',
> 'size' => 1,
> 'minitems' => 0,
> 'maxitems' => 1,
> )
> ),
>
> Problem:
> If no item of the foreign table is selected (so the
> value '0' of the items-array is used), then
> I get this error:
> #1237301367: $object must be an object or an array, boolean given.
> when I use
> {article.category.title}
> in my template.

I was not able to reproduce this with the most recent version of 
Extbase. I have added the setup to the BlogExample (administrator of a 
blog).

> 3) What, if there are even more items e.g. like in 'fe_group',
> where I have additional
> array('hide_at_login', -1),
> array('any_login', -2),
> array('usergroups', '--div--')
> items ?

For one item you can use 0 (zero) as key. More than one item works but 
is a little bit awkward. Depending on your field type in the database 
strings get transformed to 0 or NULL.

Regards
Jochen






More information about the TYPO3-project-typo3v4mvc mailing list