Skip to content
This repository was archived by the owner on Oct 20, 2025. It is now read-only.

Commit 66c2c10

Browse files
authored
Always use FormData when sending forms (#42)
1 parent c38ddde commit 66c2c10

File tree

2 files changed

+4
-21
lines changed

2 files changed

+4
-21
lines changed

lib/Components/Form.vue

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script>
2-
import { hasFiles, objectToFormData } from "./FormHelpers.js";
2+
import { objectToFormData } from "./FormHelpers.js";
33
import { Splade } from "../Splade.js";
44
import get from "lodash-es/get";
55
import has from "lodash-es/has";
@@ -43,12 +43,6 @@ export default {
4343
},
4444
},
4545
46-
forceFormData: {
47-
type: Boolean,
48-
required: false,
49-
default: false,
50-
},
51-
5246
confirm: {
5347
type: [Boolean, String],
5448
required: false,
@@ -195,10 +189,9 @@ export default {
195189
this.recentlySuccessful = false;
196190
clearTimeout(this.recentlySuccessfulTimeoutId);
197191
198-
const data =
199-
this.forceFormData || hasFiles(this.values)
200-
? objectToFormData(this.values)
201-
: this.values;
192+
const data = (this.values instanceof FormData)
193+
? this.values
194+
: objectToFormData(this.values);
202195
203196
const headers = { Accept: "application/json" };
204197

lib/Components/FormHelpers.js

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,6 @@
11
// The methods in this file are completely stolen from Inertia.js:
22
// https://github.com/inertiajs/inertia/tree/master/packages/inertia/src
33

4-
export function hasFiles(data) {
5-
return (
6-
data instanceof File ||
7-
data instanceof Blob ||
8-
(data instanceof FileList && data.length > 0) ||
9-
(data instanceof FormData && Array.from(data.values()).some((value) => hasFiles(value))) ||
10-
(typeof data === "object" && data !== null && Object.values(data).some((value) => hasFiles(value)))
11-
);
12-
}
13-
144
export function objectToFormData(source) {
155
source = source || {};
166

0 commit comments

Comments
 (0)