standardBindings
conststandardBindings:object
Defined in: extension.ts:16
Standard bindings for React form elements, by the name of the method they add to Form
Importing @mobx-sentinel/react/extension adds the methods to every form with extendFormBinding(),
and extends Form with their types.
Type Declaration
Section titled “Type Declaration”bindCheckBox
Section titled “bindCheckBox”
readonlybindCheckBox: typeofCheckBoxBinding=CheckBoxBinding
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”
readonlybindInput: typeofInputBinding=InputBinding
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”
readonlybindLabel: typeofLabelBinding=LabelBinding
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”
readonlybindRadioGroup: typeofRadioGroupBinding=RadioGroupBinding
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.
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”
readonlybindSelectBox: typeofSelectBoxBinding=SelectBoxBinding
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”
readonlybindSubmitButton: typeofSubmitButtonBinding=SubmitButtonBinding
Bind the submit button to the form.
Example
Section titled “Example”<button {...form.bindSubmitButton()}>Submit</button>bindTextArea
Section titled “bindTextArea”
readonlybindTextArea: typeofTextAreaBinding=TextAreaBinding
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), })}/>