Currently a NOT NULL field in the DB is required in Forest Admin, and the front automatically convert empty strings to null values.
It appears to us a bad design to allow empty strings in required fields, so it is not possible to do it easily in Forest Admin.
If you cannot/doesn’t want to do it otherwise, there is some workarounds :
You can hide the real NOT NULL field, and create a computed field that is not required. Forest allow to define the write method of the computed field, to make it write in the real DB field. The front will still send null values but you can replace them with empty string in this function.
collection.removeField to hide the real field in forest admin
collection.addField to create the new not required field
collection.replaceFieldWriting to define the writing method of the new field
Simpler, but you need to change your DB:
Remove the NOT NULL constraint, and replace the writing method of the field with collection.replaceFieldWriting to set an empty string when the frontend is sending null.
I decide to turn off Not Null for now. One of the big pluses for using ForestAdmin is zero code. So at this point I wont try your work around, but thanks for sharing.
Updating the text field to allow null values is not a feature that we plan to do as it hasn’t been requested by other users.
Forest Admin widgets are built to ignore the underlying database type.
A max length can be enforced through field validation.