fix: convert empty select values to null before submitting
All checks were successful
Build containers when image tags change / build-if-image-changed (backend, shorefront-backend, shorefront backend, backend/Dockerfile, git.baumann.gr/adebaumann/shorefront-backend, .backend.image) (push) Successful in 32s
Build containers when image tags change / build-if-image-changed (frontend, shorefront-frontend, shorefront frontend, frontend/Dockerfile, git.baumann.gr/adebaumann/shorefront-frontend, .frontend.image) (push) Successful in 1m27s
All checks were successful
Build containers when image tags change / build-if-image-changed (backend, shorefront-backend, shorefront backend, backend/Dockerfile, git.baumann.gr/adebaumann/shorefront-backend, .backend.image) (push) Successful in 32s
Build containers when image tags change / build-if-image-changed (frontend, shorefront-frontend, shorefront frontend, frontend/Dockerfile, git.baumann.gr/adebaumann/shorefront-frontend, .frontend.image) (push) Successful in 1m27s
This commit is contained in:
@@ -38,7 +38,13 @@ export default function EntityForm({ open, title, fields, initialValues, onClose
|
||||
|
||||
const handleSubmit = async () => {
|
||||
setSubmitting(true)
|
||||
try { await onSubmit(values) } finally { setSubmitting(false) }
|
||||
const submitted = Object.fromEntries(
|
||||
Object.entries(values).map(([k, v]) => {
|
||||
const field = fields.find((f) => f.name === k)
|
||||
return [k, field?.type === 'select' && v === '' ? null : v]
|
||||
})
|
||||
)
|
||||
try { await onSubmit(submitted) } finally { setSubmitting(false) }
|
||||
}
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user