【发布时间】:2012-04-04 01:43:21
【问题描述】:
我在后端制作了一个 TCA 表单,根据选择字段“类型”中的值会发生什么变化:
这个选择字段基本上包含选项:
- 转文本
- 网址
- 图片
I can make the system working so, that when "rte text" is chosen, it shows specified fields for "rte text", when url is chosen it shows specified fields for "url" etc..
在我的例子中,内容总是保存在“内容”字段的数据库中,而选定的类型保存在“类型”字段中。
我的问题是我还没有找到根据所选类型更改“内容”表单字段/配置的方法。
例如,当我选择“rte text”时,它应该为内容字段使用这种配置(富文本编辑器):
'content' => array (
'exclude' => 0,
'label' => 'Content',
'config' => array (
'type' => 'text',
'cols' => '30',
'rows' => '5',
'wizards' => array(
'_PADDING' => 2,
'RTE' => array(
'notNewRecords' => 1,
'RTEonly' => 1,
'type' => 'script',
'title' => 'Full screen Rich Text Editing|Formatteret redigering i hele vinduet',
'icon' => 'wizard_rte2.gif',
'script' => 'wizard_rte.php',
),
),
)
),
当我选择“图片”时,它应该为内容字段使用这种配置(文件上传器):
'content' => array (
'exclude' => 0,
'label' => 'Content',
'config' => array (
'type' => 'group',
'internal_type' => 'file',
'allowed' => '',
'disallowed' => 'php,php3',
'max_size' => $GLOBALS['TYPO3_CONF_VARS']['BE']['maxFileSize'],
'uploadfolder' => 'uploads/tx_uploadshere',
'size' => 1,
'minitems' => 0,
'maxitems' => 1,
)
),
有没有办法根据选择框中的值更改该配置。我试图将两个内容放在一个数组中,但没有按照这种方式工作。
【问题讨论】:
-
可以通过额外的一点 PHP 来实现您想要的,但我认为在一个表字段中混合不同的内容是不正确的。我认为@konsolenfreddy 建议的方法会更好。