elm-form-validations
elm-form-validations copied to clipboard
Add a formValueWithDefault function for pre-populating field
Say I want to present a form with some fields pre-filled. Given how I construct the Forms.Form ahead of time, before I have some fetched data (e.g. a user record), I would need to fill in that data as late as possible. That is, in the view function. By that time, I have the Form and a model with data. However, I do not have a way to slipping input field values into the form at this point, since "input" has already been set to "" in initFormElement
. But, if I populate the field with Form.formValueWithDefault, I can leverage whatever has been entered by the user, if anything, or I can fallback to a value from my model.
I hope that makes sense.