简体   繁体   English

禁用表单/消化功能中的字段?

[英]disabling fields in formlets/digestive-functors?

With formlets/digestive-functors, I'm trying to figure out how selectively disable fields at run-time. 我正在尝试使用formlets / digestive-functors,在运行时选择性地禁用字段。 Disabling a field would disable both the showing of the field as well as validation. 禁用字段将同时禁用该字段的显示和验证。

Contrived example: Suppose our basic form data type looks like: 人为的示例:假设我们的基本表单数据类型如下:

data Info =
  Info {
     favcolor :: String,
     deptId   :: Int,
     company  :: String,
     agree    :: Boolean
  }

but the deptId field should only be shown if the user is an employee, otherwise the company field should be shown. 但是仅当用户是雇员时才显示deptId字段,否则应显示company字段。 And the agree field should be shown if the user hasn't already clicked the "Agree" box. 如果用户尚未单击“同意”框,则应显示agree字段。

I don't want to create a different form type for each possible variation: (favcolor, deptId, agree), (favcolor, deptId), (favcolor, company, agree), (favcolor, company). 我不想为每种可能的变体创建不同的表单类型:(favcolor,deptId,同意),(favcolor,deptId),(favcolor,公司,同意),(favcolor,公司)。 What else can I do? 我还可以做些什么?

I think this breaks the digestive functors model and can't be done. 我认为这会破坏消化函子模型,无法完成。 It would make a good feature request, though! 不过,这将是一个很好的功能请求!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM