42-px / effector-forms

108 stars 16 forks source link

Reinit created form's initialValues #16

Closed appetiteOlzh closed 1 year ago

appetiteOlzh commented 1 year ago

Need an event to reinitialize the form. To overwrite the initialValues after receiving them from the back. And set them on form.reset.

Muslik commented 1 year ago

You can use setForm:

const form = createForm({})

sample({ clock: someEvent, target: form.setForm })
tplk commented 1 year ago

setForm won't reset initial values and dirty state.

Initial value is static at the moment and can't be changed.

https://github.com/42-px/effector-forms/blob/master/src/field.ts#L30-L32 https://github.com/42-px/effector-forms/blob/master/src/field.ts#L51

aanation commented 1 year ago

@appetiteOlzh @tplk

I added the setInitialForm method that overrides the initial values. That way the isDirty flag becomes false

Please, use v.1.1.0