Adds the specified field to the front of this form.
Adds the specified field to the front of this form.
This means that calling myForm.withField(field1).withField(field2)
will
give you those fields in reverse order in your submission handlers
(field2
's value first, then field1
's). It's recommended that you
instead use the withFields
or withAjaxFields
helpers, which let you add
a group of fields * all at once in proper order and leaves you with a form
that can accept submission handlers.
A new FormailtyFormProto
with the given field prepended to its
list of fields. Note that you still need to call formalize
or
ajaxFormalize
on that form if you want to attach submission
handlers.
FormalityFormProto is the starting point for creating a formality form. It uses a lot of type magic, so that is going to be detailed here. At its most basic, however, it simply tracks a type-preserving list of FieldHolderBases and provides a single function, withField, to add a new such field to the form.
Once you've added all the fields you want, call formalize. This returns a FormalityForm, on which you can set success/failure/submission handlers, and which provides the facility to convert the form down to a single CssSel instance that will properly set up the form and all of its fields.
Typing discussion ---------------
shapeless lets us track our list of fields that can be String fields, Int fields, DateMidnight fields, or any other arbitrary type, while preserving those types and their order. As we build this list up, we call withField and add fields to the list one by one.
Because of what we need to do once we convert to a FormalityForm.