diff --git a/packages/twenty-front/src/modules/settings/data-model/fields/forms/components/SettingsDataModelFieldSettingsFormCard.tsx b/packages/twenty-front/src/modules/settings/data-model/fields/forms/components/SettingsDataModelFieldSettingsFormCard.tsx index 42dc5aa133c9..4f874ae55875 100644 --- a/packages/twenty-front/src/modules/settings/data-model/fields/forms/components/SettingsDataModelFieldSettingsFormCard.tsx +++ b/packages/twenty-front/src/modules/settings/data-model/fields/forms/components/SettingsDataModelFieldSettingsFormCard.tsx @@ -1,5 +1,6 @@ import { useFormContext } from 'react-hook-form'; import styled from '@emotion/styled'; +import omit from 'lodash.omit'; import { z } from 'zod'; import { useFilteredObjectMetadataItems } from '@/object-metadata/hooks/useFilteredObjectMetadataItems'; @@ -22,6 +23,7 @@ import { settingsDataModelFieldSelectFormSchema, } from '@/settings/data-model/components/SettingsObjectFieldSelectForm'; import { RELATION_TYPES } from '@/settings/data-model/constants/RelationTypes'; +import { SETTINGS_FIELD_TYPE_CONFIGS } from '@/settings/data-model/constants/SettingsFieldTypeConfigs'; import { SettingsDataModelFieldPreviewCard, SettingsDataModelFieldPreviewCardProps, @@ -46,6 +48,20 @@ const selectFieldFormSchema = z }) .merge(settingsDataModelFieldSelectFormSchema); +const otherFieldsFormSchema = z.object({ + type: z.enum( + Object.keys( + omit(SETTINGS_FIELD_TYPE_CONFIGS, [ + FieldMetadataType.Boolean, + FieldMetadataType.Currency, + FieldMetadataType.Relation, + FieldMetadataType.Select, + FieldMetadataType.MultiSelect, + ]), + ) as [FieldMetadataType, ...FieldMetadataType[]], + ), +}); + export const settingsDataModelFieldSettingsFormSchema = z.discriminatedUnion( 'type', [ @@ -53,6 +69,7 @@ export const settingsDataModelFieldSettingsFormSchema = z.discriminatedUnion( currencyFieldFormSchema, relationFieldFormSchema, selectFieldFormSchema, + otherFieldsFormSchema, ], ); diff --git a/packages/twenty-front/src/modules/settings/data-model/fields/forms/components/SettingsDataModelFieldTypeSelect.tsx b/packages/twenty-front/src/modules/settings/data-model/fields/forms/components/SettingsDataModelFieldTypeSelect.tsx index 66e9f24e0e55..7b236d3e13f4 100644 --- a/packages/twenty-front/src/modules/settings/data-model/fields/forms/components/SettingsDataModelFieldTypeSelect.tsx +++ b/packages/twenty-front/src/modules/settings/data-model/fields/forms/components/SettingsDataModelFieldTypeSelect.tsx @@ -9,6 +9,7 @@ import { } from '@/settings/data-model/constants/SettingsFieldTypeConfigs'; import { SettingsSupportedFieldType } from '@/settings/data-model/types/SettingsSupportedFieldType'; import { Select, SelectOption } from '@/ui/input/components/Select'; +import { FieldMetadataType } from '~/generated-metadata/graphql'; export const settingsDataModelFieldTypeFormSchema = z.object({ type: z.enum( @@ -57,7 +58,7 @@ export const SettingsDataModelFieldTypeSelect = ({ defaultValue={ fieldMetadataItem && fieldMetadataItem.type in fieldTypeConfigs ? (fieldMetadataItem.type as SettingsSupportedFieldType) - : undefined + : FieldMetadataType.Text } render={({ field: { onChange, value } }) => (