根据上一个字段值在页面的 TCA 中显示字段 [英] Display field in TCA of pages based on the previous field value

查看:21
本文介绍了根据上一个字段值在页面的 TCA 中显示字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望根据我之前的字段值显示或隐藏我在 TCA 中的字段.我怎样才能做到这一点?我可以在 javascript 中完成,但可以在 TCA 中包含 javascript 吗?

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?

这里用户选择值:

$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'),
        ),
    ),
)

);

推荐答案

所以在你的情况下,它将添加这一行'displayCond' =>'FIELD:question_field:=: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'),
        ),
    ),
)

这篇关于根据上一个字段值在页面的 TCA 中显示字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆