required

how i can make if status is selected 2 option transporter should not required else it should required
Select::make('Status')
->options(['0' => 'მიმდინარე',
'1' => 'შესაკვეთი',
'2' => 'დასრულებული',
'3' => 'გაუქმებული'])
->required(),
Select::make('transporter_id')
->label('Transporter')
->relationship('transporter', 'name')
->searchable()
->requiredIf('Status', '=', '2')
Select::make('Status')
->options(['0' => 'მიმდინარე',
'1' => 'შესაკვეთი',
'2' => 'დასრულებული',
'3' => 'გაუქმებული'])
->required(),
Select::make('transporter_id')
->label('Transporter')
->relationship('transporter', 'name')
->searchable()
->requiredIf('Status', '=', '2')
3 Replies
gigiloouu
gigiloouu4mo ago
this code does not works
Bonux
Bonux4mo ago
If I remember correctly you need to add ->live() to the component or perhaps you need to add a callback function to the requiredIf(fn(Get $get) => $get['Status'] === 2 or something along those lines.
LeandroFerreira
LeandroFerreira4mo ago
->requiredIf('Status', '2') ?