felte
felte copied to clipboard
access to initial values from HTML or createForm
Is your feature request related to a problem? Please describe.
hi - i'm trying to set the form back to its original HTML values? i've tried setting a variable to $data
upon component mount to store the values but it doesnt quite work. is there an idiomatic felte way to do this?
Describe the solution you'd like
allow access to initial values from HTML or even the initialValues
inside createForm
object?
Describe alternatives you've considered
setting variable to $data
upon component mount
Additional context none
thanks for your GREAT work on this library! so good
Hey! The way to do this would be using both the reset
helper (returned from createForm) and the initialValues
configuration option. This way the initial values would be under your control.
If you (for any reason) need to change what the initialValues
will be on reset after the form has mounted, you can use the setInitialValues
helper.
thanks for the reply! yes, kinda - the issue is that i'd use setInitialValues
and reset
few times already. let me explain:
lets say we have a registration form and a list of registrations. filling out a empty form appends a registration item to the list. i also provide the ability to edit an existing registration - when the user clicks on 'edit' button, the existing registration's data is passed to the form via setInitialValues
and reset
.
after editing an registration and saving it, i'd like to be able to clear the form (back to original values) and then make new registrations.
right now - if i use setInitialValues
to allow the editing of a registration, i can't get the original form back. because reset
will always set the form to the most recent setInitialValues
/registration edit. as i try to create new registrations, the form has the data of the edit.
i hope this is clear!
hi - i also noticed that nested bits in $data aren't populated to the HTML on the first call to reset
and setInitialValues
- it populates the first level only and then the children on the second call (two button clicks)
any ideas how to fix?
here's a screencast: https://www.youtube.com/watch?v=4CUG3hX5fsE better one: https://www.youtube.com/watch?v=GhBagj_mHGM
the first-level only data population behavior applies to setFields
as well
In documentation is not clear how to use setInitialValues when creating form
setData
not working as name of function sugest