-
Notifications
You must be signed in to change notification settings - Fork 2
Form.withSections
API / Form<TValidationError> / withSections method
Adds the provided sections to the form, returns an observable collection containing them.
Any changes made to the returned collection is reflected in the form as well, added sections are added, removed sections are removed, sorting or moving sections around are moved in the form as well.
protected withSections(
...sections: readonly Form<TValidationError>[]
): FormCollection<Form<TValidationError>, TValidationError>
Source reference: src/forms/Form.ts:759
.
Returns: FormCollection<Form<TValidationError>, TValidationError>
Returns a collection containing the provided sections. The form reacts to changes made in the returned collection always keeping in sync.
In some cases the form that is being edited is rather large and having all fields put together would make the code hard to follow. It is natural to want to group fields together in such cases as it provides a way to clearly group related fields together and even reuse parts of a form.
Adding sections to a form is done similar to how fields are done, any form section is itself a form.
class MyForm extends Form {
public constructor() {
super();
this.withSections(
this.first = new MyFirstSection(),
this.second = new MySecondSection()
);
}
public readonly first: MyFirstSection;
public readonly second: MySecondSection;
}
class MyFirstSection extends Form {
// ...
}
class MySecondSection extends Form {
// ...
}
This will propagate any changes from the individual sections to the form itself making it easy to check the validity of the entire form.
Overview
Motivation
Guides and Tutorials - Getting Started
Releases
CodeSandbox
API
Events
IEvent
IEventHandler
EventDispatcher
ViewModels
INotifyPropertiesChanged
ViewModel
Forms
Form
IFormFieldConfig
FormField
ReadOnlyFormCollection
FormCollection
IConfigurableFormCollection
FormSetupCallback
Validation
IValidator
ValidatorCallback
IObjectValidator
IValidatable
Validation / Triggers
WellKnownValidationTrigger
ValidationTrigger
Observable Collection
ReadOnlyObservableCollection
ObservableCollection
INotifyCollectionChanged
CollectionChangeOperation
INotifyCollectionReordered
CollectionReorderOperation
Observable Map
ReadOnlyObservableMap
ObservableMap
INotifyMapChanged
MapChangeOperation
Observable Set
ReadOnlyObservableSet
ObservableSet
INotifySetChanged
SetChangeOperation
Dependency Handling
IDependencyResolver
IDependencyContainer
DependencyContainer
useDependency
useViewModelDependency
useDependencyResolver
React Hooks
useViewModel
useViewModelMemo
useObservableCollection
useObservableMap
useObservableSet