Dependant dropdowns don't load relationships on the Edit page.
Hello everyone. I have a resource called
Now, on
BriefResource
and the model itself has a belongsTo()
relationship to another model called ContentTypeVariation
. The ContentTypeVariation
has a belongsTo()
relationship to ContentType
model.Now, on
BriefResource.php
i have this -
When im creating a new brief, i indeed get the correct content_type_variation_id
in the DB.. but when im editing the entry, the dropdowns don't get populated at all.3 Replies
Hmm, when loading explicitly the relationship on the
EditBrief.php
file like this -
it works just fine.. but why? is it because Brief
doesn't have a direct relationship to ContentType
but only via ContentTypeVariation
? should i define some "belongsToThrough" relationship?Not sure what doesn't work in your case but I found an example from our FilamentExamples of a 3-level dependent dropdown with edit form, please compare to our code. Doesn't fit in code limit and on mobile screenshot so sending two screenshots 🙂
Also this is bad, it causes duplicate queries looking through the returned array
use
As Povilas pointed out, you can use afterStateUpdated to push the array of data too but if the first and second is reactive it should fetch fine.
ahhh the second one is a relationship I've got a field that's your problem