Adds the given event handler to the list of event handlers this field will have on the client.
Adds the given event handler to the list of event handlers this field
will have on the client. See EventHandler for more. Meant to be
used with Formality.on for fluency (e.g., field -> on("change", checkStuff _)
).
Note that FieldHolder
s are immutable; this returns a copy of this
FieldHolder
with an updated event handler list.
Aliased as handlingEvent
for folks who don't like operators.
Adds the given boxed validation to the list of validations run on this field at form processing time.
Adds the given boxed validation to the list of validations run on this
field at form processing time. Note that validations may add
attributes to the field to indicate on the client side what types of
validations are expected; see the Validation
trait for more.
Note that FieldHolder
s are immutable; this returns a copy of this
FieldHolder
with an updated validation list.
Aliased as validatingWith
for folks who don't
like operators.
Adds the given validation to the list of validations run on this field at form processing time.
Adds the given validation to the list of validations run on this field at form processing time. Note that validations may add attributes to the field to indicate on the client side what types of validations are expected; see the Validation trait for more.
Note that FieldHolders are immutable; this returns a copy of this FieldHolder with an updated validation list.
Aliased as validatingWith
for folks who
don't like operators.
Adds the passed error messages, using S.error
.
Adds the passed error messages, using S.error
. Can be overridden to use
something other than S.error
.
Defines the base transform that adds the function id and initial value to the HTML field specified in the selector parameter.
Defines the base transform that adds the function id and initial value to the HTML field specified in the selector parameter. When overriding, it is highly suggested that you call super.baseTransform and append your own transforms to that.
Provides the CSS transform that transforms an input field in the template into one that will be processed by this field's value conversion and validation functions, that will have the provided initial value, and that will run this field's associated callbacks for the event handlers it has specified.
Provides the CSS transform that transforms an input field in the template into one that will be processed by this field's value conversion and validation functions, that will have the provided initial value, and that will run this field's associated callbacks for the event handlers it has specified.
If you override the binder, please make sure you properly
map your handler function, event handlers, and validations. This
binder automatically calls generateFunctionIdAndHandler
and binds
its result to the name of the HTML field, and your code must do
something similar to ensure the server-side function you define is
called on form submission.
Computes the final field value and applies any validations.
Computes the final field value and applies any validations. Ensures validations only run once no matter how many times the field value is accessed.
This is the final computed field value after all validations have been handled.
This is the final computed field value after all validations have been
handled. It memoizes the result of computeFieldValue
.
Stores the field name generated by generateFunctionIdAndHandler
.
Stores the field name generated by generateFunctionIdAndHandler
. The
current field name should be accessed from here rather than directly
through generateFunctionIdAndHandler
except in case of clear preference.
The handler function should set this TransientRequestVar
to the
appropriate value.
The handler function should set this TransientRequestVar
to the
appropriate value.
Creates a handler function, maps it (potentially using S.fmapFunc
),
and returns the resulting function id to bind to the HTML
field.
Creates a handler function, maps it (potentially using S.fmapFunc
),
and returns the resulting function id to bind to the HTML
field. See the implementation in SimpleFieldHolder
for a sample.
This should return a copy of this BaseFieldHolder
with the
specified event handler attached.
This should return a copy of this BaseFieldHolder
with the
specified event handler attached. Left abstract because by far the
best implementation is using a case class copy method.
This should return a copy of this BaseFieldHolder with the specified validation attached.
This should return a copy of this BaseFieldHolder with the specified validation attached. Left abstract because by far the best implementation is using a case class copy method.
This should return a copy of this BaseFieldHolder with the specified validation attached.
This should return a copy of this BaseFieldHolder with the specified validation attached. Left abstract because by far the best implementation is using a case class copy method.
Returns the current value of the field.
Returns the current value of the field. If no value was seen in the last
form submission, invokes boxedValidations
and registers any resulting
validation errors.
This case class creates a field holder for a multi select field that gets a list of
Strings
from the client. IfasCheckboxes
istrue
, the binder created for this select field is designed to bind to checkboxes and their labels instead of producing a select field.When dealing with
select
elements (i.e.,asCheckboxes
isfalse
), the whole element specified byselector
will be replaced by a newselect
element.When
asCheckboxes
istrue
, the element specified byselector
will be repeated once for each of the passedoptions
. The option label will be used to set the text of thelabel
. If the checkbox is nested in thelabel
, it will be left at the end of thelabel
. If a givenSelectableOption
specifies anid
attribute, in addition to that attribute being set on the checkbox, thefor
attribute of thelabel
element (if present) will be set to the same value.