#How to set a field on relationTo media with name of parent collection.

8 messages · Page 1 of 1 (latest)

ionic tusk
#

I have a collection with a media field

// media collection
{
  slug: "media",
  fields: [
    { name: "parentCollection", type: "text" }
  ]
}
// User collection
{
  slug: "users",
  fields: [
    { name: "photo", relationTo: "media" }
  ]

on the admin screen when i create a new user i want to upload a photo, and when i upload a photo i know it goes into the media collection, but how would I populate the parentCollection field automatically so it references "users"?

winged dawnBOT
cold trench
#

Did you ever find a solution to this? Would be nice to set values from the parent

ionic tusk
#

no 😦

brazen gyro
#

did you try using one of the hooks? nit

junior hedge
#

I feel like we shouldn't need to use a hook to do something like this, I know you could grab the id from the url but I am running into the same issue. If I am on an admin screen, and I want to add a related piece of content, why wouldn't it autopopulate this for me? It seems counter intuitive.

fiery obsidian
fiery obsidian