One case class field, as HTML sees it.
Deliberately not db's Column, which is PreparedStatement and ResultSet and nothing else. A model with no database behind it still has to form, and Login(email, password) is the case that proves it: it will never be a table, and it renders and parses like anything else.
Composed over a io.eezo.core.Parser rather than being one, because how text becomes a value is not a form's question: a configuration value asks it too, from a module that never sees a browser. What a Field adds is only what an input needs, its type, its shown text and whether it renders ticked. It does not extend Parser, so a Field can never stand where a Parser is asked for, and a checkbox's lenient reading of on cannot leak into anything that is not a form.
A final class rather than a trait, so the reading has one place to live and a hand written instance cannot override read past its Parser. Field.of is how an author writes one.
absent comes from the Parser, and it is why a browser's habits need no hidden inputs here. A browser omits an unchecked checkbox entirely rather than submitting false, so "the key is missing" has to be answerable per type. Rails answers it by rendering a hidden companion input before every checkbox and then relying on last wins; that is a second mental model, and a value the server cannot distinguish from a genuine submission. Here Field[Boolean].absent is Some(false), Field[Option[X]].absent is Some(None), and everything else is None, which is exactly the set of fields that can report "is required".
Attributes
- Companion
- object
- Source
- Field.scala
- Graph
-
- Supertypes