disabling fields in formlets/digestive-functors?

137 Views Asked by At

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?

1

There are 1 best solutions below

0
On

I think this breaks the digestive functors model and can't be done. It would make a good feature request, though!