Hi! Consider I have the following collection Recipes:
import { CollectionConfig } from 'payload/types';
import IngredientUnit from '../components/IngredientUnit';
const Recipes: CollectionConfig = {
slug: 'recipes',
admin: {
useAsTitle: 'name',
},
fields: [
{
name: 'title',
type: 'text',
},
{
name: 'ingredients',
type: 'array',
fields: [
{
name: 'name',
type: 'text'
},
{
name: 'quantity',
type: 'text'
},
{
name: 'unit',
type: 'text',
admin: {
components: {
Field: IngredientUnit
}
}
}
]
}
],
}
export default Recipes;
How can I access the 'name' field inside the custom component 'IngredientUnit'? Using 'useFormFields' I am able to access the 'title' field, but not 'name'.
Thank you!!!
Hey @cerize - the useForm() function will allow you to access the sibling data. Not sure how your custom field is setup but it would look something like this:
Star
Discord
online
Get help straight from the Payload team with an Enterprise License.