on my website there is a button for users to create a new contribution. By clicking on it the user gets redirected to the strapi admin panel to create a new entry:
…/admin/content-manager/collectionType/api::contribution.contribution/create?minimal=true&groupId=3
As you can see I also add the groupId as a query parameter to the url.
Is it possible that strapi fills in the field groupId with the Id in the url?
1 Like
Ok this is a total hack, but I couldn’t find a “Strapi way” of doing this. In the bootstrap method of src/admin/app.js
, you can do something like this:
bootstrap(app) {
const pathname = window.location.pathname
if (
pathname.startsWith('/admin/content-manager/') &&
pathname.endsWith('/create')
) {
const params = new URLSearchParams(window.location.search)
const tests = {}
for (const [key, value] of params.entries()) {
const currentInterval = setInterval(function () {
const element = document.getElementById(key)
if (element) {
element.value = value
window.clearInterval(currentInterval)
}
if (tests[key] == undefined) {
tests[key] = 0
}
tests[key] = tests[key] + 1
if (tests[key] >= 20) {
window.clearInterval(currentInterval)
}
}, 200)
}
}
},
Although this seems to only work for simple text fields