Forms
Contains data manipulation helpers (typically HTTP form handling)
import play.api.data._
import play.api.data.Forms._
val taskForm = Form(
of(Task.apply _, Task.unapply _)(
"name" -> text(minLength = 3),
"dueDate" -> date("yyyy-MM-dd"),
"done" -> boolean
)
)
Attributes
- Graph
-
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
Forms.type
Members list
Value members
Concrete methods
Constructs a mapping for a BigDecimal field.
Constructs a mapping for a BigDecimal field.
For example:
Form("montant" -> bigDecimal(10, 2))
Value parameters
- precision
-
The maximum total number of digits (including decimals)
- scale
-
The maximum number of decimals
Attributes
Constructs a simple mapping for a numeric field (using a Short type behind).
Constructs a simple mapping for a numeric field (using a Short type behind).
For example:
Form("size" -> byteNumber(min=0, max=100))
Value parameters
- max
-
maximum value
- min
-
minimum value
- strict
-
should it be a strict comparison
Attributes
Constructs a simple mapping for a date field.
Constructs a simple mapping for a date field.
For example:
Form("birthdate" -> date("dd-MM-yyyy"))
Value parameters
- pattern
-
the date pattern, as defined in
java.text.SimpleDateFormat - timeZone
-
the
java.util.TimeZoneto use for parsing and formatting
Attributes
Defines an default mapping, if the parameter is not present, provide a default value.
Defines an default mapping, if the parameter is not present, provide a default value.
Form(
"name" -> default(text, "The default text")
)
Value parameters
- mapping
-
The mapping to make optional.
- value
-
The default value when mapping and the field is not present.
Attributes
Define a fixed value in a mapping. This mapping will not participate to the binding.
Define a fixed value in a mapping. This mapping will not participate to the binding.
Value parameters
- value
-
As we ignore this parameter in binding/unbinding we have to provide a default value.
Attributes
Defines a repeated mapping with the IndexedSeq semantic.
Defines a repeated mapping with the IndexedSeq semantic.
Form(
"name" -> indexedSeq(text)
)
Value parameters
- mapping
-
The mapping to make repeated.
Attributes
Defines a repeated mapping.
Defines a repeated mapping.
Form(
"name" -> list(text)
)
Value parameters
- mapping
-
The mapping to make repeated.
Attributes
Constructs a simple mapping for a date field (mapped as java.time.LocalDate type).
Constructs a simple mapping for a date field (mapped as java.time.LocalDate type).
For example:
Form("birthdate" -> localDate("dd-MM-yyyy"))
Value parameters
- pattern
-
the date pattern, as defined in
java.time.format.DateTimeFormatter
Attributes
Constructs a simple mapping for a date field (mapped as java.time.LocalDateTime type).
Constructs a simple mapping for a date field (mapped as java.time.LocalDateTime type).
For example:
Form("dateTime" -> localDateTime("dd-MM-yyyy HH:mm:ss"))
Value parameters
- pattern
-
the date pattern, as defined in
java.time.format.DateTimeFormatter
Attributes
Constructs a simple mapping for a date field (mapped as java.time.LocalTime type).
Constructs a simple mapping for a date field (mapped as java.time.LocalTime type).
For example:
Form("time" -> localTime("HH:mm:ss"))
Value parameters
- pattern
-
the date pattern, as defined in
java.time.format.DateTimeFormatter
Attributes
Constructs a simple mapping for a numeric field (using a Long type behind).
Constructs a simple mapping for a numeric field (using a Long type behind).
For example:
Form("size" -> longNumber(min=0, max=100))
Value parameters
- max
-
maximum value
- min
-
minimum value
- strict
-
should it be a strict comparison
Attributes
Creates a Mapping of type T.
Creates a Mapping of type T.
For example:
Form(
mapping(
"email" -> of[String]
)(User.apply, User.unapply)
)
Type parameters
- R
-
the mapped type
Value parameters
- apply
-
A function able to create a value of R from a value of A1 (If R is case class you can use its own apply function)
- unapply
-
A function able to create A1 from a value of R (If R is a case class you can use its own unapply function)
Attributes
- Returns
-
a mapping for type
R
Constructs a simple mapping for required text field.
Constructs a simple mapping for required text field.
Example:
Form("username" -> nonEmptyText(minLength=3))
Value parameters
- maxLength
-
Text max length.
- minLength
-
Text min length.
Attributes
Constructs a simple mapping for a numeric field.
Constructs a simple mapping for a numeric field.
For example:
Form("size" -> number(min=0, max=100))
Value parameters
- max
-
maximum value
- min
-
minimum value
- strict
-
should it be a strict comparison
Attributes
Creates a Mapping of type T.
Creates a Mapping of type T.
For example:
Form("email" -> of[String])
Type parameters
- T
-
the mapping type
Attributes
- Returns
-
a mapping for a simple field
Defines an optional mapping.
Defines an optional mapping.
Form(
"name" -> optional(text)
)
Value parameters
- mapping
-
The mapping to make optional.
Attributes
Defines a repeated mapping.
Defines a repeated mapping.
Form(
"name" -> seq(text)
)
Value parameters
- mapping
-
The mapping to make repeated.
Attributes
Defines a repeated mapping with the Set semantic.
Defines a repeated mapping with the Set semantic.
Form(
"name" -> set(text)
)
Value parameters
- mapping
-
The mapping to make repeated.
Attributes
Constructs a simple mapping for a numeric field (using a Short type behind).
Constructs a simple mapping for a numeric field (using a Short type behind).
For example:
Form("size" -> shortNumber(min=0, max=100))
Value parameters
- max
-
maximum value
- min
-
minimum value
- strict
-
should it be a strict comparison
Attributes
Creates a Mapping for a single value.
Creates a Mapping for a single value.
For example:
Form(
single(
"email" -> email
)
)
Attributes
- Returns
-
a mapping for a type A1
Constructs a simple mapping for a date field (mapped as sql.Date type).
Constructs a simple mapping for a date field (mapped as sql.Date type).
For example:
Form("birthdate" -> sqlDate("dd-MM-yyyy"))
Value parameters
- pattern
-
the date pattern, as defined in
java.text.SimpleDateFormat
Attributes
Constructs a simple mapping for a Timestamp field (mapped as java.sql.Timestamp type).
Constructs a simple mapping for a Timestamp field (mapped as java.sql.Timestamp type).
For example:
Form("birthdate" -> sqlTimestamp("dd-MM-yyyy hh:mm:ss"))
Value parameters
- pattern
-
the date pattern, as defined in
java.text.SimpleDateFormat - timeZone
-
the
java.util.TimeZoneto use for parsing and formatting
Attributes
Constructs a simple mapping for a text field.
Constructs a simple mapping for a text field.
For example:
Form("username" -> text(minLength=3))
Value parameters
- maxLength
-
maximum text length
- minLength
-
minimum text length
Attributes
Creates a Mapping of tuple (A,B).
Creates a Mapping of tuple (A,B).
For example:
Form(
tuple(
"email" -> email,
"password" -> nonEmptyText
)
)
Attributes
- Returns
-
a mapping for a tuple
(A,B)
Concrete fields
Constructs a simple mapping for a BigDecimal field.
Constructs a simple mapping for a BigDecimal field.
For example:
Form("montant" -> bigDecimal)
Attributes
Constructs a simple mapping for a Boolean field, such as a check-box.
Constructs a simple mapping for a Boolean field, such as a check-box.
For example:
Form("accepted" -> boolean)
Attributes
Constructs a simple mapping for a numeric field (using a Byte type behind).
Constructs a simple mapping for a numeric field (using a Byte type behind).
For example:
Form("size" -> byteNumber)
Attributes
Constructs a simple mapping for a char field.
Constructs a simple mapping for a char field.
For example:
Form("gender" -> char)
Attributes
Constructs a simple mapping for a date field.
Constructs a simple mapping for a date field.
For example:
Form("birthdate" -> date)
Attributes
Constructs a simple mapping for an e-mail field.
Constructs a simple mapping for an e-mail field.
Attributes
- See also
-
http://www.w3.org/TR/html5/forms.html#e-mail-state-(type=email) For example:
Form("email" -> email)
Constructs a simple mapping for a date field (mapped as java.time.LocalDate type).
Constructs a simple mapping for a date field (mapped as java.time.LocalDate type).
For example:
Form("birthdate" -> localDate)
Attributes
Constructs a simple mapping for a date field (mapped as java.time.LocalDateTime type).
Constructs a simple mapping for a date field (mapped as java.time.LocalDateTime type).
For example:
Form("dateTime" -> localDateTime)
Attributes
Constructs a simple mapping for a date field (mapped as java.time.LocalTime type).
Constructs a simple mapping for a date field (mapped as java.time.LocalTime type).
For example:
Form("time" -> localTime)
Attributes
Constructs a simple mapping for a numeric field (using a Long type behind).
Constructs a simple mapping for a numeric field (using a Long type behind).
For example:
Form("size" -> longNumber)
Attributes
Constructs a simple mapping for required text field.
Constructs a simple mapping for required text field.
Note that all field are always required to be present in the form unless there are marked as optional explicitly. But a nonEmptyText defines text field that must not be empty, even if present in the form.
Example:
Form("username" -> nonEmptyText)
Attributes
Constructs a simple mapping for a numeric field.
Constructs a simple mapping for a numeric field.
For example:
Form("size" -> number)
Attributes
Constructs a simple mapping for a numeric field (using a Short type behind).
Constructs a simple mapping for a numeric field (using a Short type behind).
For example:
Form("size" -> shortNumber)
Attributes
Constructs a simple mapping for a date field (mapped as sql.Date type).
Constructs a simple mapping for a date field (mapped as sql.Date type).
For example:
Form("birthdate" -> sqlDate)
Attributes
Constructs a simple mapping for a timestamp field (mapped as java.sql.Timestamp type).
Constructs a simple mapping for a timestamp field (mapped as java.sql.Timestamp type).
For example:
Form("birthdate" -> sqlTimestamp)
Attributes
Constructs a simple mapping for a text field.
Constructs a simple mapping for a text field.
For example:
Form("username" -> text)