I'm implementing a form with dynamic fields being added by an add field button. What I need is to prevent some of these fields to have the same value before submission.
Currently my Request rules look like this:
public function rules()
{
return [
'myfield.*.domain' => 'required|url',
'myfield.*.group' => 'required',
'myfield.*.client' => 'nullable'
];
}
For instance, what if want the domain input to be unique in the form submission (not the database)? Is this possible?
Any help would be really appreciated!
Thanks!
EDIT
Adding 'distinct' rule did the job for the specific field.
'myfield.*.domain' => 'required|url|distinct'
The validation errors though sometimes don't show up at my view. Testing the same input errors on purpose, the error messages sometimes show up as they should and sometimes $errors->all()
returns an empty array.
@foreach ($errors->all() as $error)
<div class="card-panel red white-text alert">
<span>{{ $error }}</span>
</div>
@endforeach