When creating a new item through a relationship filed, and the relationship only can contain items with a category.
{
name: "wheels",
type: "relationship",
filterOptions: (args) => {
return { category: { equals: "wheels" } };
},
relationTo: ["spare-parts"],
},
Can I set the default value for the new relationship item "wheels.category" in the remote collection to "wheels" when added through a relationship?
My solution was to disable edit and create for the relationship field.
Hi @martin.rahbek I tried your code.
But how did you set the default value?
defaultValue: () => {
// query the default and return it here
return {
value: "53673f577e92b8ea049d3ca5",
relationTo: "spare-parts",
};
},
Star
Discord
online
Get help straight from the Payload team with an Enterprise License.