简体   繁体   中英

disabling fields in formlets/digestive-functors?

With formlets/digestive-functors, I'm trying to figure out how selectively disable fields at run-time. 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. And the agree field should be shown if the user hasn't already clicked the "Agree" box.

I don't want to create a different form type for each possible variation: (favcolor, deptId, agree), (favcolor, deptId), (favcolor, company, agree), (favcolor, company). 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!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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