Allow forms to have a file upload enctype

This commit is contained in:
Alice Gaudon 2021-11-22 21:30:23 +01:00
parent 6348692473
commit f68e81836b

View File

@ -14,6 +14,7 @@
export let isBoldSubmit: boolean = true; export let isBoldSubmit: boolean = true;
export let resetButton: boolean = false; export let resetButton: boolean = false;
export let confirm: string = undefined; export let confirm: string = undefined;
export let withFiles: boolean = false;
const formId = nextAvailableFormId++; const formId = nextAvailableFormId++;
setContext('formId', formId); setContext('formId', formId);
@ -37,7 +38,7 @@
} }
</style> </style>
<form {action} method="POST" id="{formId}-form" on:submit={handleSubmit}> <form {action} method="POST" id="{formId}-form" on:submit={handleSubmit} enctype={withFiles ? 'multipart/form-data' : undefined}>
<CsrfTokenField/> <CsrfTokenField/>
<slot/> <slot/>
<div class="form-controls"> <div class="form-controls">