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

Default values are not correctly set for inputs with several occurrences on content create #8737

Closed
alansemenov opened this issue Apr 8, 2021 · 0 comments
Assignees
Labels
Projects
Milestone

Comments

@alansemenov
Copy link
Member

This content type has a TextLine input with a default value and min 3 occurrences (which means they should be created automatically).

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<content-type>
  <display-name>Test</display-name>
  <super-type>base:structured</super-type>
  <form>
    <input name="field1" type="TextLine">
      <label>Field 1</label>
      <occurrences minimum="3" maximum="3"/>
      <default>Default text</default>
    </input>
  </form>
</content-type>

In Content Studio it's rendered correctly (correct number of fields with the default value):

image

But the content is created with wrong data (only one occurrence of field1):

  "data": {
    "field1": "Default text"
  },

After first save data becomes correct:

  "data": {
    "field1": [
      "Default text",
      "Default text",
      "Default text"
    ]
  },

This is also a problem with container inputs (like item-sets) that have several occurrences.

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<content-type>
  <display-name>ItemSet</display-name>
  <super-type>base:structured</super-type>
  <form>
    <input name="field1" type="TextLine">
      <label>Field 1</label>
      <occurrences minimum="1" maximum="1"/>
      <default>Default text</default>
    </input>
    <item-set name="field2">
      <label>Field 2</label>
      <items>
        <input name="label" type="TextLine">
          <label>Label</label>
          <occurrences minimum="1" maximum="1"/>
          <default>Default text</default>
        </input>
      </items>
      <occurrences minimum="3" maximum="3"/>
    </item-set>
  </form>
</content-type>

Content Studio:

image

Wrong data on create (only one occurrence of field2):

  "data": {
    "field1": "Default text",
    "field2": {
      "label": "Default text"
    }
  },

Correct data after save:

  "data": {
    "field1": "Default text",
    "field2": [
      {
        "label": "Default text"
      },
      {
        "label": "Default text"
      },
      {
        "label": "Default text"
      }
    ]
  },
@alansemenov alansemenov added the Bug label Apr 8, 2021
@rymsha rymsha added this to Needs triage in Bugs via automation Apr 8, 2021
@rymsha rymsha added this to the 7.6.2 milestone Apr 9, 2021
@rymsha rymsha moved this from Needs triage to High priority in Bugs Apr 26, 2021
rymsha pushed a commit that referenced this issue Apr 27, 2021
@rymsha rymsha moved this from High priority to Closed in Bugs Apr 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
No open projects
Bugs
Closed
Development

No branches or pull requests

3 participants