Skip to content

Relation Widget Fails Without Intelligent Error Message #1074

@DomtronVox

Description

@DomtronVox

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

- What is the current behavior?
If you put an invalid value for searchFields it fails with a "sorry there was an error", but no details anywhere what the error was.

In my case I created a new collection that had a relation widget field. I mistakenly set the searchFields value to "[title]" instead of ["title"]. What really threw me off was that it allowed me to create new pages for the collection, but the message-less error page would show up when I tried to edit created pages.

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

  1. Add a relation field and place a string in for searchFields.
  2. Create a new page for the collection.
  3. Try to edit the page.
  4. You should receive a very minimal error page that isn't helpful. Looking at the devtools JS console will also show no error messages that are easily understandable. I think there was some convoluted traceback about a toJS function not existing, but can't remember exactly. I tried tracing it at one point, but couldn't find an answer.

- What is the expected behavior?
The error page should have a message stating the searchFields value is of the wrong type or that there is no field named the given value in the given collection.

And Thank you for all the great work you guys put into this software!

- Please mention your CMS, node.js, and operating system version.

1.0, v8.1.3 local ( not sure what version netlify uses), and Ubuntu Linux (but I was testing it on netlify's system through the web)

- Please link or paste your config.yml below if applicable.
I don't think this would be helpful but here it is:

  - name: "sub_page"
    label: "Sub Pages"
    folder: "src/documents/sub_pages"
    create: "true"
    slug: "{{slug}}"
    fields:
      - {label: "Title", name: "title", widget: "string", tagname: "h1"}
      - {label: "Navigation Bar Text", name: "navTitle", widget: "string"}
      - {label: "Which Main Page to sort navigation button under.", name: "navNest", widget: "relation", collection: "main_page", searchFields: "[title]", valueField: "title"}
      - {label: "Navigation bar priority (lower=farther up)", name: "navPriority", widget: "number"}
      - {label: "Body", name: "body", widget: "markdown"}
      #hidden fields are not editable by the user but still show up in the file's front matter
      - {label: "Collection", name: "collection", widget: "hidden", default: "SubPage"}
      - {label: "Layout", name: "layout", widget: "hidden", default: "default.html"}
    meta:
      - {label: "Publish Date", name: "date", widget: "datetime", format: "YYYY-MM-DD hh:mm:ss"}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions