Save "empty string" fields does not appear to work for MSSQL

Hello @David_Martin,

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 :

  1. 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
  1. 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.