F
Filamentβ€’14mo ago
Chriis

$get('foo') return an id in a 1-n relationship field

Hi, I have three 1-n relationship field in my form and they return the id of the Resource selected even if I see the name in the select input. Is it possible to have another column instead of the id in this context ? The alternative is to make requests to the DB with the id, but I'm really surprised there is no other way ... Help would be really appreciated πŸ™‚
No description
12 Replies
Chriis
ChriisOPβ€’14mo ago
No description
Chriis
ChriisOPβ€’14mo ago
No description
Sanchit Patil
Sanchit Patilβ€’14mo ago
->afterStateUpdated(function($get,$set, YourModel $record){
$getters = [
'course' => $record->relationship->field_name,
];
}
->afterStateUpdated(function($get,$set, YourModel $record){
$getters = [
'course' => $record->relationship->field_name,
];
}
this might help.
Chriis
ChriisOPβ€’14mo ago
Oh ok, I will try that thx 😁
Chriis
ChriisOPβ€’14mo ago
😬
No description
Chriis
ChriisOPβ€’14mo ago
No description
Chriis
ChriisOPβ€’14mo ago
I just want the acronym of the relationship value I have selected πŸ₯²
Sanchit Patil
Sanchit Patilβ€’14mo ago
have you loaded the model? use App\Models\Sheet
Chriis
ChriisOPβ€’14mo ago
Yes
No description
Chriis
ChriisOPβ€’14mo ago
But is it really possible to perform a relationship method on the record even if it haven't been saved ?
Sanchit Patil
Sanchit Patilβ€’14mo ago
this should be used only for edit method
Chriis
ChriisOPβ€’14mo ago
Ah ok so I have no choice to do db find() request with ids
Want results from more Discord servers?
Add your server