Field

io.eezo.http.Field
See theField companion object
trait Field[X]

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.

absent is the whole reason the trait has four members rather than three. 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
class Object
trait Matchable
class Any

Members list

Value members

Abstract methods

def inputType: String

The type attribute of the rendered ``.

The type attribute of the rendered ``.

Attributes

Source
Field.scala
def read(text: String): Either[String, X]

Reads submitted text, or says why it will not read. The message is what reaches the user, so it reads as a predicate about the value rather than as a parser's complaint.

Reads submitted text, or says why it will not read. The message is what reaches the user, so it reads as a predicate about the value rather than as a parser's complaint.

Attributes

Source
Field.scala
def show(x: X): String

The field's value as submitted text.

The field's value as submitted text.

Attributes

Source
Field.scala

Concrete methods

def absent: Option[X]

The value to use when the key is not in the submission at all, if there is one.

The value to use when the key is not in the submission at all, if there is one.

Attributes

Source
Field.scala