form-js
form-js copied to clipboard
Make it possible to show a loading state on inputs
Is your feature request related to a problem? Please describe
In order to lazy load values for inputs we need to show a loading state on the inputs in case the request takes too long. For more context read #60
Describe the solution you'd like
The library could adopt the concept of a field state and make it possible for the user to change the state of each field:
form.setFieldState('fieldName', 'loading'); // states could be extended to other things like readOnly, etc
// or
form.setField('fieldName', { state: 'loading' });
Describe alternatives you've considered
We could also have a more generic approach like on Bootstrap input addons
const loadingSpinnerElement = createLoadingSpinner();
form.setFieldSuffixAddon('fieldName', loadingSpinnerElement);
// or
form.setField('fieldName', { suffixAddon: loadingSpinnerElement });