[TYPO3-dev] TCA, set allowed files based on record type

Thomas "Thasmo" Deinhamer thasmo at gmail.com
Fri Feb 4 16:25:54 CET 2011


Hi all!

In the TCA of my table I got this field:

'files' => array(
	'exclude' => 1,	
	'label' => 'Files',
	'config' => array(
		'type' => 'group',
		'internal_type' => 'file',
		'allowed' => 'gif,png,jpg,jpeg,webm,mp4,ogv,wav,mp3',
		'max_size' => 1024,
		'uploadfolder' => 'uploads/',
		'size' => 3,
		'autoSizeMax' => 10,
		'minitems' => 0,
		'maxitems' => 100,
		'show_thumbs' => TRUE,
	),
),

which accepts all sorts of file types.

Now I added a 'type' field to the table
which lets me choose a media type:

'type' => array(
	'exclude' => 1,
	'label' => 'Type',
	'config' => array(
		'type' => 'select',
		'default' => 'image',
		'items' => array(
			array('Image', 'image'),
			array('Video', 'video'),
			array('Audio', 'audio'),
		),
	),
),

For every media type a specific set of file types
should be allowed for the 'files' field. I don't wanna
add 3 different 'files' fields, one for every media type,
but I'd like to rather dynamically change the 'allowed'
definition when the type of the record is changed.

Is there any chance of using some "simple" code inside
the tca.php, or will I need to code a TCA "save hook"?

Thanks a lot,
Thomas




More information about the TYPO3-dev mailing list