Package Versions:
I would like to make the copy_permis
field required or not depending on the specialty selected.
I have two models Candidat(id,name,specialty_id)
and Specialty(id,name,is_required )
. NB: is_required : is boolean
Forms\Components\Select::make('specialty_id')
->required()
->live()
->searchable()->preload()
->relationship('specialty','name'),
Forms\Components\FileUpload::make('copie_permis')
->directory('permis_files')
->openable()
->downloadable()
->image()
->imageEditor()
->required(fn (Get $get): bool => ($get('specialty_id.is_required') == true)),
I expect to check the value of is_required to decide if it's required or not.
->required(fn (Get $get): bool => Specialite::select('cp_requise')->where('id', $get('specialite_id'))->pluck('cp_requise')->join('/'))