Netlify-cms: maximum and minimum number of items in the list widget

Created on 2 Jul 2018  路  9Comments  路  Source: netlify/netlify-cms

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

- What is the current behavior?

Currently the list widget will allow us to add many list items with no virtual limit.

- What is the expected behavior?
I propose an option for the list widget that allows us to set the maximum and minimum number of items in a list.

extensionwidgets good first issue pinned feature

Most helpful comment

I'd like to try my hand on this one

All 9 comments

Totally, makes sense.

I'm working on it 馃檪!

@erquhart @tech4him1 PR is opened : https://github.com/netlify/netlify-cms/pull/1527

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

I was just about to make a feature request for this. Would like to see this added if anyone is still working on it

@robbevp best way to push this forward is to up vote the issue as we us it for prioritization. See here the most up voted ones.

Would really love to see this feature implemented as well.

Would also love to see this implemented. It would really help when using the Variable Types List Widget, so that the user cannot accidentally add more than 1 page template per page. Take this as an example. Without a limit on template key, the user can add more than 1 template per page in this case. You'd almost always want the option to restrict the page template to a value of 1.

collections:
  - name: Page
    label: page
    create: true
    folder: 'src/_pages/pages'
    extension: md
    slug: '{{slug}}'
    fields:
      - label: 'Title'
        name: 'title'
        type: 'string'
        default: 'Add a page'
      - label: 'Page Template'
        name: 'template'
        widget: 'list'
        types:
          - label: 'Standard Layout'
            name: 'standardLayout'
            widget: 'object'
            fields:
              - { label: 'Heading', name: 'sectionTitle', widget: 'string' }
              - {
                  label: 'Home Block Sections',
                  name: 'homeBlockSections',
                  widget: 'object',
                  fields:
                    [
                      { label: 'Heading', name: 'sectionTitle', widget: 'string' },
                      {
                        label: 'First Block',
                        name: 'firstBlock',
                        widget: 'object',
                        fields:
                          [
                            { label: 'Heading', name: 'heading', widget: 'string' },
                            { label: 'Text', name: 'text', widget: 'text' },
                          ],
                      },
                      {
                        label: 'Middle Block',
                        name: 'secondBlock',
                        widget: 'object',
                        fields:
                          [
                            { label: 'Heading', name: 'heading', widget: 'string' },
                            { label: 'Text', name: 'text', widget: 'text' },
                          ],
                      },
                      {
                        label: 'End Block',
                        name: 'thirdBlock',
                        widget: 'object',
                        fields:
                          [
                            { label: 'Heading', name: 'heading', widget: 'string' },
                            { label: 'Text', name: 'text', widget: 'text' },
                          ],
                      },
                    ],
                }

I'd like to try my hand on this one

Was this page helpful?
0 / 5 - 0 ratings