[TYPO3-mvc] Displaying a model property of type 'select' as form field using Extbase and Fluid

Thomas "Thasmo" Deinhamer thasmo at gmail.com
Tue Jan 19 23:10:29 CET 2010


Good evening folks!

Recently I created a database table for an extension,
added TCA definitions and an Extbase model etc. - all working well.

Now I needed to display this field, coming from the table,
using the <f:form.select/> viewhelper:

'field' => array(
	'label' => 'Field',
	'config' => array(
		'type' => 'select',
		'items' => array(
			array('Menge: Stück', 0),
			array('Menge: Laufmeter', 1),
			array('Masse: Kilogramm', 2),
			array('Volumen: Liter', 3),
		),
		'size' => 1,
		'minitems' => 0,
		'maxitems' => 1,
	),
),

I came accross the fact, that the 'items' to render as select
field options, are not directly available inside my model,
nor the action controller dealing with the model.

Furthermore, for a completely localized extension, the items
inside the TCA config need to be translated, which results
in defining them with the syntax 'LLL:EXT:MyExt...'. This
even makes this more complicated, as the strings need to
be fetched from a locallang file first, for the desired language.

(I guess it would be easier to create new translations, matching
the ones in the locallang_db.file, inside a locallang.db file,
for the frontend - apparently recommended anyway?)

The select viewhelper needs an argument, holding an array or
object, providing those option values, either with key-value
pairs for the array, or with getters for an object.

For the question now: Does there exist an easy approach or
a best-practice already, for getting those TCA items and
serving them to Fluid? If not, what would be a good solution?

Where should the TCA be processed, creating objects or array
which can be used inside a controller or a model?

This really bugs me, as I can't find a neat and easy solution.

Thanks a lot for your suggestions and solutions!

Best regards,
Thomas


More information about the TYPO3-project-typo3v4mvc mailing list