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?
2 Replies
LeandroFerreira
LeandroFerreiraβ€’16mo 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
IndomieRendangβ€’16mo ago
You're the best! πŸ‘ 🀝 Thanks!