A principled model for forms
Over the past two years, we’ve experimented with a bunch of different ways to build forms, including the whole range from what we might call mutate all the things! to do nothing without an action! Each of those ends of the spectrum has significant pain points. Indeed: we recently built another couple of large forms, one of which used lots of mutability and one of which did exactly the opposite: modifying everything via actions. Both had serious pain points. Thinking on that, plus Danielle Adams’ EmberConf talk “Mastering the Art of Forms”, crystallized a couple things for me into what I think is a coherent way of approaching forms in general. So here we go:
- Every form has its own model, where the model is a data structure representing each form field’s type, current value, validation rules, and current validity. The form validity is the composition of the validity of all its fields using the validations.
- If an input chan