Closed frankbits closed 8 months ago
I was actually thinking about a slightly related thing yesterday: Do we need the “Required” label on the Object widget? And here comes the issue!
I just tested the config with Netlify/Decap CMS, which gave the same result, and found the same issue: https://github.com/decaporg/decap-cms/issues/2103
I think the current behaviour is okay because an Object field is just a grouping and conditionally bypassing nested required fields is rather confusing. A better UX might be to allow an optional Object field to be explicitly removed (and re-added if necessary) with a button, similar to a List field.
Thoughts?
You mean, that currently it always tries to add the object, as it's not first checking for its content.
And you now propose, an object-field would work like a list-field with max: 1
. Sounds good.
Continuing to think in this direction, it may be possible to allow different object-types...🤔
I'm currently using a workaround for that, with widget: list
where max: 1
and types:
are set...
don't really know how/if that could be implemented logically...😶
but I think the object-field would still need the required-option deciding, if it can be saved if it's removed.
It’s a good idea to introduce variable types to the Object widget! One of my clients uses list widget variable types in Sveltia CMS and I know it works well. 👍🏻
For required: false
on Object, I’d implement the Add/Remove button as proposed. And I need to rewrite the validation code, which is buggy especially on the List widget.
This will be shipped with the next minor release. I’ve realized that one of my clients has this use case — currently setting required: false
to all the subfields to avoid validator errors, but I can remove the workaround once the fix is in 😄
Shipped 🚢
src
&url
have to be set.You should be able to save, if an optional object is empty