How to enable or disable fields based on select in edit page ?

i have 2 select field which is diabled in edit and want to enabled only when channel_id 's value =="website" and similarly status select is only editable when channel is website otherwise both are disabled :Select::make('channel_id') ->label('Channel') ->disabled() ->relationship('channel', 'name') ->preload() ->searchable() ->columnSpan([ 'default' => 3, 'sm' => 3, 'md' => 1, 'xl' => 1, '2xl' => 1, ]), Select::make('status') ->required() ->options(get_marketplace_config('order_status')) ->columnSpan([ 'default' => 3, 'sm' => 3, 'md' => 1, 'xl' => 1, '2xl' => 1, ]),
No description
4 Replies
Hugo
Hugo15mo ago
->disabled(fn($get) => $get('channel_id') !== "website")
->disabled(fn($get) => $get('channel_id') !== "website")
Try this ? On "status" select
Ali Abbas
Ali AbbasOP15mo ago
@hugomyb Thanks for your reply yeh this work for status slecet but how can we handle channel ?
Hugo
Hugo15mo ago
To activate the "channel_id" select if the value is "website"? On channel_id select :
->disabled(fn($state) => $state !== "website")
->disabled(fn($state) => $state !== "website")
Does it work ? @aliabbas8356
Ali Abbas
Ali AbbasOP15mo ago
@hugomyb i am checking w8t @hugomyb this is working perfectly thanks 😊
Want results from more Discord servers?
Add your server