How to get the select option label using $get?

Select::make('category')->relationship('category', 'name')->reactive(),
TextInput::make('slug')->prefix(fn ($get) => $get('category').'/')
Select::make('category')->relationship('category', 'name')->reactive(),
TextInput::make('slug')->prefix(fn ($get) => $get('category').'/')
From the code above, the slug prefix returns the 'id' of the category, of course.... But how to get the label instead of the value?
3 Replies
LeandroFerreira
LeandroFerreiraβ€’2y ago
TextInput::make('slug')
->prefix(fn ($component) => $component->getContainer()->getComponent('data.category')?->getOptionLabel())
TextInput::make('slug')
->prefix(fn ($component) => $component->getContainer()->getComponent('data.category')?->getOptionLabel())
?
IndomieRendang
IndomieRendangOPβ€’2y ago
You're the best! πŸ‘ 🀝 Thanks!
Gandalf
Gandalfβ€’4mo ago
Does the way remain the save in Filament 3.x?
Want results from more Discord servers?
Add your server