Filling records from a table into a Select input when the resource have no direct relationship
Hi, like the title say, I have a Resource and in the creation form I want to have a select which contains another resource records. The problem is these resources have zero direct relationship.
How can I achieve that ?
16 Replies
->options(fn () => OtherModel::get()->pluck('name', 'id')->toArray)
Ok thanks
Also, can I call a relationship of this Model ? Even if I'm in another Resource/Model ?
This is the schema, the creation form I'm talking about is the Sheet one. In this form I have a select which is filled with every competency_framework record, and depending on this select result, I display another select (multiple this time) with every competencies of this competency_framework
So does your model has relation or not? Use said it doesn't but in the screen it has belongstomany
Yes the Sheet Resource has 0 relation with the CompetencyFramework one π
However, competency framework intervenes in the Sheet creation form only for filtering the competencies (in relation n-n with sheet)
If I understand correctly you want this
Yes, I looked at this example multiple times but the fact that the data is hardcoded make the comprehension a little bit more difficult
Replace hard-coded data with your own
Should work
(its the doc btw)
Yes, but could you explain to me the options() line of 'sub_category', pls
I don't understand the Collection => ...
It's a return type
A php thing
Well yes but π
You know what, I'm going to figure that out xD
Its the arrow function syntax that got me confused I think, my bad
Arrow is just shorter version of function () { return ... }
Yep I've done a quick reminder on that π