Skip to content
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

List widget not enforcing required fields or default values #1360

Closed
joeptacek opened this issue May 15, 2018 · 2 comments
Closed

List widget not enforcing required fields or default values #1360

joeptacek opened this issue May 15, 2018 · 2 comments

Comments

@joeptacek
Copy link

joeptacek commented May 15, 2018

- Do you want to request a feature or report a bug?

Bug

- What is the current behavior?

For a collection that includes a list widget, when I add a new item to the list, but don't provide values in any of the fields, I am able to save changes without complaint from the UI. The resultant object within that list within that collection item is missing any keys for which I omitted values. This is true for list fields with required: true as well as for fields where required key is unspecified (assumed required by default).

For example, I can save this (see screenshot) even when list items One / Two / Three are required (implicitly or explicitly). Also note missing default value for Three.

I have not tested regex validation for list fields, but also wonder about that.

grab

- If the current behavior is a bug, please provide the steps to reproduce.

Push below config.yml to GitHub, open the CMS UI after everything builds on Netlify, add new collection item, add a value to one of the required collection fields (e.g., title), add new list item, omit all fields for new list item, click save.

- What is the expected behavior?

I was expecting to see the same behavior as when omitting values for required fields not contained within lists, i.e., I wasn't expecting the UI to permit saving. Also was expecting to see default values pre-filled by the UI.

- Please mention your versions where applicable.

Netlify CMS version: 1.7.0
Browser version: Chrome 66.0.3359.139

Node.JS version:
Operating System:

- Please link or paste your config.yml below if applicable.

backend:
  name: git-gateway
  branch: develop-netlify
publish_mode: editorial_workflow
media_folder: "assets/netlify"
collections:
- name: "example"
  label: "Example"
  folder: "_example"
  create: true
  fields:
  - {name: "title", label: "Title", widget: "string"}
  - {name: "default", label: "Default", widget: "string", default: "foo"}
  - name: "test"
    label: "Test"
    widget: "list"
    fields:
    - {name: "one", label: "One", widget: "string"} # implicitly required by default?
    - {name: "two", label: "Two", widget: "string", required: true} # explicitly required
    - {name: "three", label: "Three", widget: "string", default: "foo"} # specifying default
@erquhart
Copy link
Contributor

This is a duplicate of #467. Can you add any additional info there?

@joeptacek
Copy link
Author

Got it, sorry about that!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants