Open georgeemr opened 1 year ago
@georgeemr createForm
exposes a Svelte writable store named form
. In your case, you can use a reactive block to fetch the data from the server when the form changes, and use .update()
from the store to update your values.
E.g.,
$: {
// fetch data from API
form.update(data => ({ ...data, firstName: API_RESULT_FIRSTNAME, lastName: API_RESULT_LASTNAME, lastName1: API_RESULT_LASTNAME1 }))
}
Edit: specify which Svelte writable store is exposed
Is there a way that I can modify the value of the initialValues when using the helper components? I want to change 3 inputs when one input changes because I want to get from the server the values.
const initialValues = { identification: "", // --> When input, i want to change firstname, lastname, and lastname2 with values from the server firstName: "", lastName1: "", lastName2: "" };
I'm unable to call a custom function and change the values directly because the Form don;t detect the change and because of that the form says the value is required.