twenty icon indicating copy to clipboard operation
twenty copied to clipboard

In field creation/edition, setting a defaultValue on an enum type and changing the type to boolean disable the save button

Open Weiko opened this issue 9 months ago • 1 comments

Bug Description

In field creation/edition, setting a defaultValue on an enum type and changing the type to boolean disable the save button

https://github.com/twentyhq/twenty/assets/1834158/d33fd440-1960-463b-8e5c-eb13fa2970f8

Technical inputs

Probably related to the fact that those types use defaultValues, which is not the case for TEXT for example (and changing to TEXT works)

Weiko avatar May 14 '24 16:05 Weiko

Disclaimer: This comment was automatically generated with AI. It can give some useful hints as to where to look for, but sometimes it can also give very inaccurate answers so takes this with a pinch of salt :). The issue appears to be related to form validation not properly handling changes between field types that use defaultValues differently, such as enum and boolean. To address this, ensure that the form validation logic in SettingsDataModelFieldSettingsFormCard.tsx and the useForm hook in SettingsObjectNewFieldStep2.tsx and SettingsObjectFieldEdit.tsx correctly resets or updates validation rules when the field type changes. Specifically, look into how settingsDataModelFieldSettingsFormSchema and the form's mode and resolver are configured to handle changes in field types. This might involve dynamically adjusting the validation schema or manually triggering form validation upon type change.

References

/packages/twenty-front/src/pages/settings/data-model/SettingsObjectNewField/SettingsObjectNewFieldStep2.tsx /packages/twenty-front/src/pages/settings/data-model/SettingsObjectFieldEdit.tsx /packages/twenty-front/src/modules/settings/data-model/fields/forms/components/SettingsDataModelFieldSettingsFormCard.tsx /packages/twenty-front/src/modules/settings/components/SaveAndCancelButtons/SaveButton.tsx

Ask Greptile

greptile-apps[bot] avatar May 14 '24 16:05 greptile-apps[bot]