Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/lib/components/Formly.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@

// Props.
export let fields: IField[] = [];

export let defaultButtons = true;
export let btnSubmit: IBtnSubmit = {
text: 'Submit'
};
Expand All @@ -73,7 +75,6 @@
};

export let form_name: string = '';
export let realtime: boolean = false;
let _formEl: HTMLFormElement;

// Dispatch values.
Expand Down Expand Up @@ -145,9 +146,8 @@
// Update form.
storeForms.save(current_form);

if (realtime) {
dispatch('update', { ...current_form.values, valid: current_form.valid });
}
dispatch('update', { ...current_form.values, valid: current_form.valid });

};

// Submit form.
Expand All @@ -163,6 +163,8 @@
});
await storeForms.resetValues(form_name);
current_form.values = values;

dispatch('reset', { ...values, valid: current_form.valid });
};
</script>

Expand Down Expand Up @@ -193,6 +195,7 @@
<Dirty {field} />
{/if}
{/each}
{#if defaultButtons}
<button
type="submit"
class={btnSubmit.classes && btnSubmit.classes?.length ? btnSubmit.classes?.join(' ') : null}
Expand All @@ -204,6 +207,7 @@
class={btnReset.classes && btnReset.classes?.length ? btnReset.classes?.join(' ') : null}
>{btnReset.text}</button
>
{/if}
</form>
{/if}
{/if}