Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
Set default value for field? #269
Is it possible to set a default value for a field? I've been perusing the code, but I don't see any obvious way to do so. My use case is a form that has values pre-populated (e.g. the user is returning to edit a form that they've already completed).
I can manually set the values by storing a
I tried setting
This variable is then extended onto the field options, overwriting it. I was able to get the behavior I'm looking for by changing the line to
and then iterating each of my fields to call
Would you consider a pull request to set the model automatically if an
Alternatively, if I'm missing something and this is already built in, please tell me how to do it! :)
Watch the first video on this page:
Toward the end I talk about this.
Let me know if you have more questions. Please close this issue if this
(Sent from my mobile device, please forgive typos or brevity)
The approach you mention in your video (
This works fine, but it gets difficult to reason about once you start nesting fields to accomplish some of the more advanced layouts. Some of this difficulty can be alleviated by using a recursive function, but it's still not as intuitive (for me, at least) as having Formly set the model value automatically.
Quick note on this - if