feat(front/Form): allow overriding onSubmit function

This commit is contained in:
Alice Gaudon 2022-02-28 14:43:36 +01:00
parent 7a49e47ae7
commit 0e0e633e08

View File

@ -19,11 +19,11 @@
const formId = nextAvailableFormId++; const formId = nextAvailableFormId++;
setContext('formId', formId); setContext('formId', formId);
function handleSubmit(e) { export let onSubmit = function(e) {
if (confirm && !window.confirm(confirm)) { if (confirm && !window.confirm(confirm)) {
e.preventDefault(); e.preventDefault();
} }
} };
</script> </script>
<style lang="scss"> <style lang="scss">
@ -38,7 +38,7 @@
} }
</style> </style>
<form {action} method="POST" id="{formId}-form" on:submit={handleSubmit} enctype={withFiles ? 'multipart/form-data' : undefined}> <form {action} method="POST" id="{formId}-form" on:submit={onSubmit} enctype={withFiles ? 'multipart/form-data' : undefined}>
<CsrfTokenField/> <CsrfTokenField/>
<slot/> <slot/>
<div class="form-controls"> <div class="form-controls">