two column as unique
i have this form
return $form
->schema([
Forms\Components\Select::make('program_id')
->relationship('program', 'name')
->required(),
Forms\Components\Select::make('applicant_id')
->relationship('applicant', 'name')
->required(),
Forms\Components\TextInput::make('values')
->required(),
Forms\Components\Select::make('status_id')
->relationship('status', 'name')
->required(),
]);
i need program_id and applicant _id as unique in table at same time
7 Replies
do you need to more details any knowledge?
This isnt filament related right?
no its filament
how in filament form i take program_id and applicant_id unique at same time in database is unique but filament how will do to ckeck
Look at : https://filamentphp.com/docs/3.x/forms/validation#unique
You can create this by modifyRuleUsing
yes this for one column what if two column is unique at same time i dont no if my question is correct
You can also create you own rule : https://filamentphp.com/docs/3.x/forms/validation#custom-rules
Something like this i think
this mean i will the same for the two ones but in your condition the correct is or or and because i need the two column with same values exit as unique in DB
Forms\Components\Select::make('program_id')
->relationship('program', 'name')
->required(),
Forms\Components\Select::make('applicant_id')
->relationship('applicant', 'name')
->required(),