How do I make a unique() field with the id of the resource?

I'm trying to perform a unique() validation on a TextInput, but I need the resource's ID. I'm using request('record') when I'm on the edit page but request('record') is empty.
2 Replies
Vp
Vp2y ago
like this ->unique(ignoreRecord: true) you can check more from here https://filamentphp.com/docs/2.x/forms/validation#unique
Filament
Validation - Form Builder - Filament
The elegant TALL stack form builder for Laravel artisans.
kevin
kevin2y ago
Thanks for your reply but I'm trying this
TextInput::make('name')
->unique(
callback: function (Unique $rule) {
return $rule->where('client_id', request('record'));
})
->required()
TextInput::make('name')
->unique(
callback: function (Unique $rule) {
return $rule->where('client_id', request('record'));
})
->required()
The TextInput(name) is inside a repeater with a role relationship. Role names cannot be repeated for one client, but other clients can have the same roles. However, with ignoreRecord:true, I am unable to perform that validation
Want results from more Discord servers?
Add your server