F
Filament8mo ago
Zeynal

How to change the suffix value of a component after select component setted

I want to change the suffix value of the component when the platform is selected. how can I do this?
No description
11 Replies
Zeynal
Zeynal8mo ago
I have read this page many times. how can I access the suffix property of the other component in the afterStateUpdated method?
lazydog
lazydog8mo ago
Form/Get in your callback/closure function parameter function (Form/Get $get) { dd($get('field_name'); }
Zeynal
Zeynal8mo ago
Yes, I try this but it only returns me the value of the component. for example 1,2,3
lazydog
lazydog8mo ago
Please share your code
Zeynal
Zeynal8mo ago
No description
Dennis Koch
Dennis Koch8mo ago
You need to think the other way around. You don't set a method from ->afterStateUpdated(). That method can return a different value based on another field thought. So instead of ->afterStateUpdated() you use
->helperText(
fn (Get $get) => $get('platform_id') == 1 ? '@facebook.com' : '@otherplatform.com'
)
->helperText(
fn (Get $get) => $get('platform_id') == 1 ? '@facebook.com' : '@otherplatform.com'
)
lazydog
lazydog8mo ago
It's better to share your code, now it's clear that afterStateUpdated is not the right way to resolve your issue
Zeynal
Zeynal8mo ago
I really didn't expect it to work like this. It's really great. Thank you so much for saving my day.
Zeynal
Zeynal8mo ago
@Dennis Koch So is there an easier way of this code? Platform::find($get('platform_id'))->name; I mean, can I get it from the component instead of getting it from the database?