trait FormControllerBase extends HasValues with HasTouches with HasErrors
A component to manage data editing lifecycle. Supply the initial values and optionally track fine-grained changes. Very few assumptions are made in this base class leaving the details to subclasses. A react context is provided for child components, if desired.
The form can be used as controlled or uncontrolled. Provide a "value" parameter to ake it controlled. Controlled is a better model if you have components (such as a reset button) outside the form's structure that can alter the value being edited.
- To do
Remove dependency on Future. Make general F or use js.Promise.
- Alphabetic
- By Inheritance
- FormControllerBase
- HasErrors
- HasTouches
- HasValues
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Type Members
- sealed trait Action extends AnyRef
Actions that are sent by child form elements.
- case class Context(props: FormProps, initialValue: Value, validate: UndefOr[FormValidator]) extends Product with Serializable
The context is slightly duplicative in that initialValues and validate are already in FormProps.
- case class FieldErrors(errors: Errors, merge: Boolean) extends Action with Product with Serializable
Set field errors.
Set field errors. Either replacing all of the existing or merging this into the existing field errors.
- case class FieldValue(field: String, value: Value, validate: Boolean) extends Action with Product with Serializable
Send the attibute that changed and an updated Value object.
- case class FormActions(setFieldValue: (String, Value, Boolean) => Unit = (_, _, _) => (), setError: (String, String) => Unit = (_, _) => (), setErrors: (Errors, Boolean) => Unit = (_, _) => (), setTouched: (String, Boolean) => Unit = (_, _) => (), submit: () => Unit = () => (), reset: (Option[Value]) => Unit = _ => (), validateField: (String) => Future[Errors] = _ => Future.successful(EmptyErrors), validateForm: (Value) => Future[Errors] = _ => Future.successful(EmptyErrors)) extends Product with Serializable
API to change this this component's state, church encoding of Actions.
API to change this this component's state, church encoding of Actions. Most of these send state changing messages to the reducer. This API is should be easier to use then sending raw Action messages.
- case class FormHandlers(handleChange: (String, Value) => Unit = (_, _) => (), handleBlur: (String) => Unit = _ => (), handleSubmit: react.vdom.FormEventHandler[Form] = _ => (), handleReset: react.vdom.FormEventHandler[Form] = _ => ()) extends Product with Serializable
Handlers for controls.
Handlers for controls. These are close to what's needed for most html controls.
- case class FormProps(isValid: Boolean, dirty: Boolean, values: Value, errors: Errors, touched: Touches, isValidating: Boolean, isSubmitting: Boolean, submitCount: Int, didMount: Boolean, handlers: FormHandlers, actions: FormActions, initialValue: Value) extends Product with Serializable
Props passed to the child component.
- type FormValidator = (Value, Seq[String]) => Future[Errors]
Validate values, only checking Seq[String] fields, or all fields (form level validation) if Nil.
Validate values, only checking Seq[String] fields, or all fields (form level validation) if Nil. Return errors.
- trait Props extends Object with PropsBase
- Annotations
- @JSType()
- trait PropsBase extends Object
- Annotations
- @JSType()
- trait PropsInit extends Object with PropsBase
- Annotations
- @JSType()
- case class Reset(values: Value) extends Action with Product with Serializable
Reset using the values provided including initialValues.
- type ResetCallback = (Value, FormActions) => Future[Unit]
- case class State(value: Value, postAction: Option[Action] = None, submitting: Boolean = false, validating: Boolean = false, resetting: Boolean = false, errors: Errors = EmptyErrors, touched: Touches = EmptyTouches) extends Product with Serializable
- type SubmitCallback = (Value, FormActions) => Future[Unit]
- case class Submitting(f: Boolean) extends Action with Product with Serializable
Submit the form.
Submit the form.
- f
Whether submission should start or if it has ended.
- case class Touched(field: String, validate: Boolean) extends Action with Product with Serializable
Touch a field potentially forcing validation.
- case class Validating(f: Boolean, errors: Option[Errors]) extends Action with Product with Serializable
Indicate whether we are validating, performed asynchronously.
Indicate whether we are validating, performed asynchronously. This action does not perform validation itself, it just provides the status or the result of validation if f = false.
- f
validating status "is or is not validating"
- errors
validation errors from the validation ffort, if any
- type Validator = (Option[Any]) => Future[String]
Validate a single value, return user message.
Validate a single value, return user message. Used for field level validations.
- type Validators = Dictionary[Validator]
Validators indexed by attribute name.
Abstract Value Members
Concrete Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- val EmptyValidators: Dictionary[Validator]
- val FormContext: ReactContext[Context]
- def apply(props: PropsInit)(children: (FormProps) => ReactNode): ReactNode
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native() @HotSpotIntrinsicCandidate()
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- def handleReset(currentValue: Value, dispatch: Dispatch[Action], initialValue: MutableRef[Value], factions: FormActions, reset: UndefOr[ResetCallback]): react.vdom.FormEventHandler[Form]
- def handleSubmit(dispatch: Dispatch[Action]): react.vdom.FormEventHandler[Form]
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def makeFormActions(currentValue: Value, dispatch: Dispatch[Action], initialValue: MutableRef[Value], validate: UndefOr[FormValidator]): FormActions
- def makeFormHandlers(currentValue: Value, dispatch: Dispatch[Action], initialValue: MutableRef[Value], factions: FormActions, reset: UndefOr[ResetCallback]): FormHandlers
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- val render: (Props) => ReactNode
- def resetForm(dispatch: Dispatch[Action], initialValue: MutableRef[Value], nextValues: Option[Value]): Unit
- def runFieldLevelValidations(validators: Dictionary[Validator], values: Value): Future[Errors]
Dummy for now.
Dummy for now. Always return EmptyErrors.
- def runValidations(values: Value, fieldLevelValidators: Dictionary[Validator], handler: UndefOr[FormValidator]): Future[Errors]
Run validation handlers.
Run validation handlers. Merge resulting errors. Maybe the return value should be Future[Option[Errors]]. If the validators fail, return the exception in the Future's error channel.
TODO: Keep all errors by using an applicative non-empty list.
- def setError(dispatch: Dispatch[Action], field: String, message: String): Unit
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- AnyRef → Any
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])