在extbase / fluid中创建imagefield

时间:2013-09-27 08:04:08

标签: typo3 fluid extbase

在我的TCA配置中,我有以下代码:

'image' => array(
    'exclude' => 0,
    'label' => 'LLL:EXT:myext/Resources/Private/Language/locallang_db.xml:tx_myext_domain_model_modelname.image',
    'config' => array(
        'type' => 'group',
        'internal_type' => 'file',
        'uploadfolder' => 'uploads/tx_myext',
        'show_thumbs' => 1,
        'size' => 5,
        'allowed' => $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'],
        'disallowed' => '',
        'eval' => 'required'
    ),
),

我添加了'eval' => 'required'(最后一行),但图片仍然不是必需的。

关于文本'eval' => 'required'之类的其他元素:

'homepage' => array(
    'exclude' => 0,
    'label' => 'LLL:EXT:myext/Resources/Private/Language/locallang_db.xml:tx_myext_domain_model_modelname.homepage',
    'config' => array(
        'type' => 'input',
        'size' => 30,
        'eval' => 'trim,required'
    ),
),

最后一个问题:如何制作图像?

2 个答案:

答案 0 :(得分:6)

minitems设为1。

'image' => array(
    'exclude' => 0,
    'label' => 'LLL:EXT:next_itrocksfirmen/Resources/Private/Language/locallang_db.xml:tx_myext_domain_model_modelname.image',
    'config' => array(
        'type' => 'group',
        'internal_type' => 'file',
        'uploadfolder' => 'uploads/tx_myext',
        'show_thumbs' => 1,
        'size' => 5,
        'allowed' => $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'],
        'disallowed' => '',
        'minitems' => 1
    ),
),

http://docs.typo3.org/typo3cms/TCAReference/Reference/Columns/Group/Index.html

答案 1 :(得分:2)

根据TCA ref要求groupselect类型字段,您需要配置'minitems' => 1如果ypu想要,您还可以设置maxitems设置图像计数的上限。