decaporg / decaporg/decap-cms

Using query params to pre-populate the editor on a relation widget with multiple set to true

Open
#7,794 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
19.4k
Forks
3.1k
Avg merge
1d 14h
Merged PRs (30d)
9

Description

Hello!

I've got a collection that looks like this:
```
collections:
- name: datasets
label: Datasets
label_singular: Dataset
folder: _datasets
create: true
fields:
- label: Cities
name: cities
widget: relation
collection: "cities"
search_fields: ["city_id"]
value_field: "city_id"
display_fields: ["title"]
multiple: true
```

For other collections/fields, I can pass query params to pre-populate the editor like so:
`/editor/#/collections/datasets/new?title=sometitle`
`/editor/#/collections/datasets/new?city=city`

But this doesn't work on `multiple: true` relation widgets, e.g.
`/editor/#/collections/datasets/new?cities=somecity`
`/editor/#/collections/datasets/new?cities=[somecity]`
`/editor/#/collections/datasets/new?cities=somecity&cities=someothercity`

These don't pre-populate at all :(

Is there a way to do this kind of thing with `multiple: true` relation widgets?

Thanks for your work on this project!

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.