我有一个字段A(下拉)和一个字段B(文本字段),具体取决于字段A的值 - 字段B变为可选字段,例如:
如果字段A的值是1;然后字段B成为必需,为此我使用SuiteCRM带来的JS函数:addToValidate
但如果字段A的值为0,我应该将字段B转换为可选
在最后一种情况下,我可以使用SuiteCRM的哪些JS功能?
谢谢
答案 0 :(得分:0)
如果您想要更改是否需要动态字段,请查看Dependency Actions。
它们允许您根据自定义Sugar Logic公式的值自动切换给定目标字段的必需状态(true / false)。
根据链接的示例和您的示例,它看起来像这样:
./custom/Extension/modules/<module>/Ext/Dependencies/fieldB_required.php
<?php
$dependencies['<module>']['fieldB_required'] = array(
'hooks' => array("edit"),
//Trigger formula for the dependency. Defaults to 'true'.
'trigger' => 'true',
'triggerFields' => array('fieldA'),
'onload' => true,
//Actions is a list of actions to fire when the trigger is true
'actions' => array(
array(
'name' => 'SetRequired', //Action type
//The parameters passed in depend on the action type
'params' => array(
'target' => 'fieldB',
'label' => '<field label>', //normally <field>_label
'value' => 'equal($fieldA, 1)', //Formula
),
),
),
);
fieldA
是一个字段,当更改时,触发重新评估公式,并设置目标 的目标 / em>字段fieldB
为equal($fieldA, 1)
的值。
注意: