Hello, I just wanted to clarify that this scenario is as I describe and expected so we can workaround it:
- Have existing schema
- Create content for that schema
- Add field with a default value to that schema that is “Required”
- Go to the existing content
- Try to save or publish that content
- Validation fails as those new fields have no value despite being having default values
There are a couple of ways we can workaround this:
- Bulk update content after field is added to populate it
- Use the scripts to populate it when not present
I am just now worried that if we do not do the bulk update we will have some content with those fields and some without, unless the API defaults them for us when reading them?
I assume we cannot just have a background worker to amend existing content when a field is added as it would mean a whole load of events that could trigger a whole lot of Rules?
Edit: The script approach doesn’t work as the client side validation around “Required” fields kicks in before scripts get run. Here’s what I tried so let me know if I did something fundamentally wrong!
But the workaround for this is obviously to also set it to NOT be a required field, and if someone tries to set it as “unspecified” then it will just default to false.