Skip to content

Orchestrate multiple entries based on an other collection #12022

Answered by r1tsuu
robbertstevens asked this question in Q&A
Discussion options

You must be logged in to vote

Hey @robbertstevens, I think there are at least 2 ways to approach this

The first way is using the react admin panel hooks.
You can use the useField hook here https://payloadcms.com/docs/admin/react-hooks#usefield to "watch" the changes of the projectTypes (or how it's called on your side) field and change the variables field.

import { useDocumentInfo, useField } from '@payloadcms/ui'

// Component
const { value: projectTypes } = useField({ path: 'projectTypes' }) 
const { value: variables, setValue: setVariables } = useField({ path: 'variables' })
const { id } = useDocumentInfo() // if id is undefined that means we're currently creating a project, not editing
const isEditing = Boolean(id)

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@robbertstevens
Comment options

Answer selected by robbertstevens
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants