-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Nested non-required object validation does not work #2103
Comments
@selaux could you please edit your config file like so:
|
Hi, yes that might work in this specific case (when there is one property). But my usecase is that either |
…ted object widgets (decaporg#2103)
I am running into this issue as well. On some collection pages, I have an optional primary field that has several sub-fields—some required and some optional—and I cannot save a new page because of the required sub-fields (only relevant if someone is going to include that primary field, which they don't have to), even though the primary field is optional. |
@selaux @maxgardner technically the widget option |
@barthc Is this intended or does it have historical reasons? One way I could think of to improve this would be instead of setting empty values such as Another way would be to reflect requiredness in the ui and allow to add and remove property values to/from objects manually (by some kind of +/- buttons to the object editor ui). |
I think it makes sense this way cause there is a widget option |
I'm honestly not certain what the original intent was, but the use cases mentioned here are sensible and should be supported. That said, and as @barthc points out, field validation may not be the right tool for the job. List widget Object widget Thoughts? Sent with GitHawk |
@barthc That makes sense; thanks for explaining. The field validation definitely seems like it's working as expected in that case, and this particular problem is out of its scope. @erquhart I think the conditional display of certain objects based on the user selecting to include that object would work well as a solution for my scenario; so long as the validation of any required sub-fields also was contingent upon this display status. Seems the issue you linked addresses that pretty clearly. Thank you! |
Is there any timeline on allowing object widget fields have the option "required: false"? This is a feature/bug problem I have run into inadvertently. |
Is there any progress on this? If not, I'd be willing to submit a PR that adds an "omit value" checkbox to the object widget, that collapses it and treats all fields inside as not required. |
@bigblind this seems like a workaround. We are looking for objects to force their |
Marking the object as optional would still be done via the configuration.
The checkbox or toggle would only show up for object fields configured to
be optional, and checking it indicates you want to omit the object
entirely, This then means that a required field in an object is still
required if the object is included in the data.
I personally don’t think that is a hacky workaround, it just adds Ui to
produce any output that’s allowed by the schema.
|
The original request is: don't validate the object if all fields are empty, but do validate if at least one field is not empty. To achieve this, we don't need a new UI toggle, but we have to update the object validation to allow that. |
Ok. I interpreted it as a more general request to allow omitting the values in optional object fields, didn't know the specific UX of just leaving fields blank was set in stone. |
Describe the bug
When an non-required object inside an object has required fields, the object widgets validation ignores the non-required attribute of the object and highlights the required sub fields of the non-required object as required.
To Reproduce
Expected behavior
Entry saved correctly because
some-metadata-property
is not required.Current behavior
Entry is not saved and
property-specific-string
is shown as required.Screenshots
Applicable Versions:
CMS configuration
The text was updated successfully, but these errors were encountered: