FilamentF
Filament3y ago
Gush

get select record on relation manager attach form

Hey, i need help understanding how do i get the equipment id i selected on form in order to make a custom rule checking for existing records with the same equipment_id and serial_number

here is the code

->rule(static function (Forms\Get $get, Forms\Components\Component $component): Closure {
                                return static function (string $attribute, $value, Closure $fail) use ($get, $component) {

                                    $equipmentID = ;

                                    $existingRecord = DB::table('construction_has_equipment')
                                        ->where('serial_number', $value)
                                        ->where('equipment_id', $equipmentID)
                                        ->exists();

                                    if ($existingRecord) {
                                        $fail(__('construction-equipment.construction_equipment_resource.error'));
                                    }
                                };
                            }),
Solution
how about $get($action->getRecordSelect()->getName())?
Was this page helpful?