Closed IamSAB closed 2 years ago
Hey SAB
You're right the value
property shouldn't be a setter, since it is not implemented to work as one ^^
At the moment you can set the initial value as you did in your example or by setting the value of the html element directly.
<input name="somethingFields" value="This will be the initial value" />
Regarding setting the value after the reset, you could do the following:
$form.controlName.reset({value: "This will be the new value"});
It isn't the cleanest way but idk it could help you.
You could also try to set the value by setting it directly to the html element. (haven't tested that and it isn't a solution which I would recommend)
In the near future I would like to have a functioning setter for the value of a control but sadly im kinda busy right now. LMK if you have further questions or suggestions :)
Hi noahsalvi, any update on the reset feature? I like the simplicity of this form library, keep it up :D
Hi noahsalvi, any update on the reset feature? I like the simplicity of this form library, keep it up :D
Hey sorry for the delay!
By reset feature do you mean the thing i wanted to implement in the near future?
If you are then good news, it's implemented and available through the method change
on the FormControl object.
e.g. $form.name.change("hello")
...But since you used "reset" im not fully sure that this is what you meant.
How can I set the initial values for the form? As I understand, I cannot simply call
useForm(data)
wheredata
is a plain javascript object, but have to build an object like:{name1: {initial: "myvalue}, name2: { initial: "myvalue"}}
. Or how to do that programatically`Further I tried to figure out, how to give new data to the form after initialization. Resetting works (calling
$form.reset()
) but assign new data withuseForm()
throws an error:Uncaught Error: Function called outside component initialization
. II can set a new value via$form.name.element[0].value = "value"
, but thenreset()
function will not work anymore. Using the$form.name.value
setter does not reflect the value in my form.Thank you for the clarification. Like the simplicity use-form :D.