Form.withFields - Andrei15193/react-model-view-viewmodel GitHub Wiki
API / Form<TValidationError> / withFields method
Adds the provided fields to the form, returns an observable collection containing them.
Any changes made to the returned collection is reflected in the form as well, added fields are added, removed fields are removed, sorting or moving fields around are moved in the form as well.
protected withFields(
...fields: readonly FormField<any, TValidationError>[]
): IObservableCollection<FormField<any, TValidationError>>
Source reference: src/forms/Form.ts:701
.
Returns: IObservableCollection<FormField<any
, TValidationError>>
Returns a collection containing the provided fields. The form reacts to changes made in the returned collection always keeping in sync.
This method adds the provided fields to the form, a necessary step to watch the form fields for
changes as well as their validity. The Form.isValid
and Form.isInvalid
properties
are dependent on the fields.
class MyForm extends Form {
public constructor() {
super();
this.withFields(
this.name = new FormField({
name: 'name',
initialValue: ''
})
);
}
public readonly name: FormField<string>;
}