StandardExtensions
Defined in: extension.ts:17
Standard binding extensions for React form elements
Form will be extended with these methods.
Remarks
Section titled “Remarks”This interface exists for the sole purpose of documentation.
Members
Section titled “Members”bindCheckBox
Section titled “bindCheckBox”bindCheckBox:
RequiredConfig<T, typeofCheckBoxBinding>
Defined in: extension.ts:91
Bind the checkbox field to the form.
Example
Section titled “Example”<input {...form.bindCheckBox("boolean", { getter: () => model.boolean, setter: (v) => (model.boolean = v), })}/>bindInput
Section titled “bindInput”bindInput:
RequiredConfig<T, typeofInputBinding>
Defined in: extension.ts:43
Bind the input field to the form.
<input> except the following types: button, submit, reset, hidden, image, file, checkbox, and radio.
For checkbox and radio, use bindCheckBox and bindRadioGroup respectively, and for <textarea>, use bindTextArea.
Example
Section titled “Example”<input {...form.bindInput("string", { getter: () => model.string, setter: (v) => (model.string = v), })}/><input {...form.bindInput("number", { valueAs: "number", // also supports "date" getter: () => model.number, setter: (v) => (model.number = v), })}/>bindLabel
Section titled “bindLabel”bindLabel:
OptionalConfig<T, typeofLabelBinding>
Defined in: extension.ts:147
Bind the label to the form.
Example
Section titled “Example”<label {...form.bindLabel(["field1"])}>Label</label><label {...form.bindLabel(["field1", "field2"])}>Label</label>bindRadioGroup
Section titled “bindRadioGroup”bindRadioGroup: <
V>(fieldName:Name<T>,config:RadioGroupBinding.Config<V> &Config) => (option:V,config?:RadioGroupBinding.ButtonConfig) =>object
Defined in: extension.ts:123
Bind the radio group field to the form.
The type of the options is inferred from the getter, and the setter receives the option of the selected button. It returns a function that takes an option and returns the props of its radio button.
Type Parameters
Section titled “Type Parameters”V extends RadioGroupBinding.Option
Parameters
Section titled “Parameters”fieldName
Section titled “fieldName”Name<T>
config
Section titled “config”RadioGroupBinding.Config<V> & Config
Returns
Section titled “Returns”(
option,config?):object
Parameters
Section titled “Parameters”option
Section titled “option”V
Option that the radio button stands for
config?
Section titled “config?”RadioGroupBinding.ButtonConfig
Returns
Section titled “Returns”object
aria-errormessage
Section titled “aria-errormessage”aria-errormessage:
string|undefined
aria-invalid
Section titled “aria-invalid”aria-invalid:
boolean|undefined
checked
Section titled “checked”checked:
boolean
id:
string|undefined
name:
string
onChange
Section titled “onChange”onChange:
ChangeEventHandler<HTMLInputElement,HTMLInputElement>
onFocus
Section titled “onFocus”onFocus:
FocusEventHandler<HTMLInputElement>
type:
"radio"="radio"
value:
string
Example
Section titled “Example”const bind = form.bindRadioGroup("enum", { getter: () => model.enum, setter: (v) => (model.enum = v),});Object.values(SampleEnum).map((value) => ( <input key={value} {...bind(value)} />))Or with renderRadioGroup from @mobx-sentinel/react:
renderRadioGroup({ binding: form.bindRadioGroup("enum", { getter: () => model.enum, setter: (v) => (model.enum = v), }), options: Object.values(SampleEnum), renderOption: (value, bind) => <input {...bind()} />,})bindSelectBox
Section titled “bindSelectBox”bindSelectBox:
RequiredConfig<T, typeofSelectBoxBinding>
Defined in: extension.ts:76
Bind the select box field to the form.
Example
Section titled “Example”<select {...form.bindSelectBox("single", { getter: () => model.code, setter: (v) => (model.code = v), })}> ...</select>bindSubmitButton
Section titled “bindSubmitButton”bindSubmitButton:
OptionalConfig<T, typeofSubmitButtonBinding>
Defined in: extension.ts:136
Bind the submit button to the form.
Example
Section titled “Example”<button {...form.bindSubmitButton()}>Submit</button>bindTextArea
Section titled “bindTextArea”bindTextArea:
RequiredConfig<T, typeofTextAreaBinding>
Defined in: extension.ts:59
Bind the textarea field to the form.
Example
Section titled “Example”<textarea rows={4} {...form.bindTextArea("string", { getter: () => model.string, setter: (v) => (model.string = v), })}/>