Skip to content

Bug: repeatable generation merged creation mixed results #133

@Snugug

Description

@Snugug

@scottnath commented on Mon Oct 31 2016

When content-types merges a content type with input plugins and there is a repeatable attribute, then it wraps that set of inputs in an array instead of making it an object and it creates multiple versions of the same input object with minor differences to increment the id.

Problems

  1. Creates a more complicated merged ct to parse
  2. Creates confusing select options

Steps for Reproducing

  • create a content type with a repeatable attribute
  • look at the post-merge output from content-types

example code

Configuration YAML:

  - type: reference
    id: bar-reference
    name: Bar reference
    repeatable:
      min: 5
      max: 10
    inputs:
      reference:
        settings:
          contentType: services

Merged content type from CT:

{
        "name": "Bar reference",
        "description": "An input plugin with reference",
        "validation": {},
        "inputs": [
          {
            "reference": {
              "validation": {
                "function": "referenceValidation",
                "on": "change"
              },
              "type": "select",
              "reference": true,
              "label": "Bar reference",
              "options": [],
              "settings": {
                "view": "select",
                "placeholder": "-- Choose One --",
                "contentType": "services"
              },
              "id": "9ba6bfd3-8a59-48fe-8bc7-e2f15e89d8cc--0",
              "name": "bar-reference--reference--0"
            }
          },
          {
            "reference": {
              "validation": {
                "function": "referenceValidation",
                "on": "change"
              },
              "type": "select",
              "reference": true,
              "label": "Bar reference",
              "options": [],
              "settings": {
                "view": "select",
                "placeholder": "-- Choose One --",
                "contentType": "services"
              },
              "id": "9ba6bfd3-8a59-48fe-8bc7-e2f15e89d8cc--1",
              "name": "bar-reference--reference--1"
            }
          },
          {
            "reference": {
              "validation": {
                "function": "referenceValidation",
                "on": "change"
              },
              "type": "select",
              "reference": true,
              "label": "Bar reference",
              "options": [],
              "settings": {
                "view": "select",
                "placeholder": "-- Choose One --",
                "contentType": "services"
              },
              "id": "9ba6bfd3-8a59-48fe-8bc7-e2f15e89d8cc--2",
              "name": "bar-reference--reference--2"
            }
          },
          {
            "reference": {
              "validation": {
                "function": "referenceValidation",
                "on": "change"
              },
              "type": "select",
              "reference": true,
              "label": "Bar reference",
              "options": [],
              "settings": {
                "view": "select",
                "placeholder": "-- Choose One --",
                "contentType": "services"
              },
              "id": "9ba6bfd3-8a59-48fe-8bc7-e2f15e89d8cc--3",
              "name": "bar-reference--reference--3"
            }
          },
          {
            "reference": {
              "validation": {
                "function": "referenceValidation",
                "on": "change"
              },
              "type": "select",
              "reference": true,
              "label": "Bar reference",
              "options": [],
              "settings": {
                "view": "select",
                "placeholder": "-- Choose One --",
                "contentType": "services"
              },
              "id": "9ba6bfd3-8a59-48fe-8bc7-e2f15e89d8cc--4",
              "name": "bar-reference--reference--4"
            }
          }
        ],
        "html": "{% if reference.type == \"radio\" %}<ul>{% for option in reference.options %}<li><input type=\"{{reference.type}}\" name=\"{{reference.name}}\" id=\"{{reference.id}}--{{loop.index}}\" value=\"{{option.value}}\" {% if option.value == reference.value %}checked{% endif %}><label for=\"{{reference.id}}--{{loop.index}}\">{{option.label}}</label></li>{% endfor %}</ul>{% else %}<label for=\"{{reference.id}}\">{{reference.label}}</label><select id=\"{{reference.id}}\" name=\"{{reference.name}}\">{% for option in reference.options %}<option value=\"{{option.value}}\"{% if option.value == reference.value %}selected{% endif %}>{{option.label}}</option>{% endfor %}</select>{% endif %}",
        "id": "bar-reference",
        "type": "reference",
        "repeatable": {
          "min": 5,
          "max": 10
        }
      },

Screenshots

screen shot 2016-10-31 at 4 51 59 pm

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions