Hi! Currently i'm building a website that's need a virtual field that is visible and not editable to user (There is a way to do that on payload website)
However, it's a calculated field that's need to fetch the data from another collection. Good example is product item inside order.
Is there a way to display the subtotal in each array box and the grand total outside the block while the admin is creating order? Thank you
You should probably use a custom component here
https://payloadcms.com/docs/beta/admin/fields#the-field-componentSee this slug field for inspiration (v3)
https://github.com/payloadcms/payload/blob/beta/templates/website/src/fields/slug/SlugComponent.tsxYou can essentially listen in on data from other fields, do whatever you need and display it as needed
Thank you so much! I will try it tomorrow.
if I want to change the component dynamically I would have to use react client instead of server? Right since the field component will be render in the server not dynamically?
yep
you can also write a server component that returns a client if you need to pass down some logic to it
you cant use the local API in the client server so there you need to use the rest api
as in your slug field it is using client component right? In my case where you need to listen to data input as you choose (relationship) is it much better to use client component or server component?
client
it will be able to get it from the state
Thank you so much!
Star
Discord
online
Get dedicated engineering support directly from the Payload team.