F
Filament13mo 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
ZeynalOP13mo ago
I have read this page many times. how can I access the suffix property of the other component in the afterStateUpdated method?
lazydog
lazydog13mo ago
Form/Get in your callback/closure function parameter function (Form/Get $get) { dd($get('field_name'); }
Zeynal
ZeynalOP13mo ago
Yes, I try this but it only returns me the value of the component. for example 1,2,3
lazydog
lazydog13mo ago
Please share your code
Zeynal
ZeynalOP13mo ago
No description
Dennis Koch
Dennis Koch13mo 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
lazydog13mo ago
It's better to share your code, now it's clear that afterStateUpdated is not the right way to resolve your issue
Zeynal
ZeynalOP13mo ago
I really didn't expect it to work like this. It's really great. Thank you so much for saving my day.
Zeynal
ZeynalOP13mo 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?
Want results from more Discord servers?
Add your server