tv2regionerne / statamic-private-api

MIT License
3 stars 2 forks source link

Patch updates are failing on assets and entries fields #11

Closed SylvesterDamgaard closed 4 months ago

SylvesterDamgaard commented 4 months ago

When doing a PATCH request on an entry it fails on Assets and Entry fields with a max of 1. It looks like the output of the merge data is just a string and not in the format expected by the API/Validation.

E.g. this response on a PATCH with empty body.

{
    "message": "The Author field must be an array. (and 3 more errors)",
    "errors": {
        "author": [
            "The Author field must be an array.",
            "The Author field must not have more than 1 items."
        ],
        "asset": [
            "The Asset field must be an array.",
            "The Asset field must not have more than 1 items."
        ]
    }
}

Blueprint used in this test:

title: Test
tabs:
  main:
    display: Main
    sections:
      -
        fields:
          -
            handle: title
            field:
              type: text
              required: true
              validate:
                - required
          -
            handle: content
            field:
              type: markdown
              display: Content
              localizable: true
          -
            handle: author
            field:
              type: users
              display: Author
              default: current
              localizable: true
              max_items: 1
          -
            handle: template
            field:
              type: template
              display: Template
              localizable: true
          -
            handle: asset
            field:
              max_files: 1
              mode: list
              container: assets
              restrict: false
              allow_uploads: true
              show_filename: true
              show_set_alt: true
              type: assets
              display: Asset
              listable: hidden
              instructions_position: above
              visibility: visible
              replicator_preview: true
              hide_display: false
          -
            handle: asset_multi
            field:
              mode: list
              container: assets
              restrict: false
              allow_uploads: true
              show_filename: true
              show_set_alt: true
              type: assets
              display: 'Asset Multi'
              listable: hidden
              instructions_position: above
              visibility: visible
              replicator_preview: true
              hide_display: false
  sidebar:
    display: Sidebar
    sections:
      -
        fields:
          -
            handle: slug
            field:
              type: slug
              localizable: true
              validate: 'max:200'