diff --git a/packages/builder/src/components/database/DataTable/modals/CreateEditColumn.svelte b/packages/builder/src/components/database/DataTable/modals/CreateEditColumn.svelte index 270e4b6e25..1e5e23823c 100644 --- a/packages/builder/src/components/database/DataTable/modals/CreateEditColumn.svelte +++ b/packages/builder/src/components/database/DataTable/modals/CreateEditColumn.svelte @@ -24,11 +24,7 @@ } let originalName = field.name - - $: required = - field.constraints && - field.constraints.presence && - !field.constraints.presence.allowEmpty + $: required = field && field.constraints && field.constraints.presence async function saveColumn() { backendUiStore.update(state => { @@ -50,6 +46,14 @@ field.type = type field.constraints = constraints } + + const getPresence = required => (required ? { allowEmpty: false } : false) + + const requiredChanged = ev => { + const req = ev.target.checked + field.constraints.presence = req ? { allowEmpty: false } : false + required = req + }