Hey guys, wondering how to go about this.
Basically I'd like to have two select fields, where the options in the second depend on the first. Let's say in the first I'm selecting countries and in the second - cities.
I can add
admin.condition
to the second field, but I'm wondering if it's possible to add condition to the option itself within that field.
With the current setup, I'll need to have a new
select
field for each option from the first field, rather than keeping the select field and have dynamic options. It'll result in this:
countries
,
cities_Gb
,
cities_Fr
,
cities_Es
, etc. Ofc that's just an example and thankfully I'm not doing THAT. 😄 But I'd like to keep only
cities
.
I could always build my own component as well, I guess. But wondering if there's something I'm missing. Thanks!
I see, thanks for confirming. I guess I'll have to do it with a custom component. 🙂
There's no way to set select options dynamically currently if you mean this. Only through a custom component.
Your custom component can access the data with
useFormFields
hook, then you basically should forward all the props to the default
SelectField
while overriding
options
prop.
Star
Discord
online
Get dedicated engineering support directly from the Payload team.