Display field in TCA of pages based on the previous field value

為{幸葍}努か 提交于 2019-12-08 11:20:20

问题


I would like to achieve that my field in TCA will be shown or hidden based on my previous field value. How can I do that? I can do it in javascript, but is possible to include a javascript in TCA?

Here user choose value:

$fields = array(
'question_field' => array(
    'label' => 'user choose',
    'config' => array(
        'type' => 'select',
        'items' => array(
        array('Yes','1'),
        array('No','0'),
        ),
    ),
)

);

if the value is yes, i would like to display second field:

$fields = array(
'second_field' => array(
    'label' => 'second question',
    'config' => array(
        'type' => 'select',
        'items' => array(
        array('Yes','1'),
        array('No','0'),
        ),
    ),
)

);


回答1:


So in your case, it will be adding this line 'displayCond' => 'FIELD:question_field:=:1', so final solution will looks like this:

$fields = array(
'second_field' => array(
    'label' => 'second question',
    'displayCond' => 'FIELD:question_field:=:1',
    'config' => array(
        'type' => 'select',
        'items' => array(
        array('Yes','1'),
        array('No','0'),
        ),
    ),
)



回答2:


You need displayCond for that. It‘s well documented with examples in TCA documentation. Please note you can switch TYPO3 version of documentation page bottom left to match your version.



来源:https://stackoverflow.com/questions/43070362/display-field-in-tca-of-pages-based-on-the-previous-field-value

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!