【发布时间】:2017-04-22 02:59:08
【问题描述】:
Silverstripe Display Logic 在 CMS 中的表单上完美运行,但我无法让它在前端的表单上运行,特别是 Bootstrap 表单。
它会隐藏元素,但在应用逻辑时不会显示它。
//If the wetsuit dropdown is equal to custom then show the fins numerical field.
DisplayLogicWrapper::create(NumericField::create("Fins","Fins"))->displayIf("Wetsuit")->isEqualTo('Custom')->end(),
我看到它只需要显示从无更改为阻止。 有没有办法做到这一点,这样它也能保持页面重新加载的状态?下拉值将保存为数据库条目。
编辑:这在 CMS 中有效,但在前端无效 - Custom 是枚举值的一部分。
DropdownField::create("Wetsuit","Wetsuit")
->setSource(singleton('DiveEquipment')->dbObject('Wetsuit')->enumValues())
->setEmptyString('Select one'),
NumericField::create('Fins','Fins')
->displayIf('Wetsuit')
->isEqualTo('Custom')
->end(),
EDIT2:使用 SilversTripe 3.5、Bootstrap Forms 1.20 和 Display Logic 1.0.8
1.0.8 已经过时了。
【问题讨论】:
-
因此,如果您将
Wetsuit下拉值更改为Custom,Fins字段不会显示?您是否验证过实际下拉值包含Custom?也许您需要发布您的下拉创建代码。 -
没错,是的。它将显示在 CMS 中,但不会显示在前端。该值确实包含
Custom。我看到前端有 JS 错误。将更新 OP。 -
我猜你需要包含 entwine...
-
包含?
/framework/thirdparty/jquery-entwine除非我遗漏了某些东西并需要将其包含在其他地方?以前从未使用过缠绕。
标签: forms logic frontend silverstripe