Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

dimdot's avatar

Dynamic fields should not have same value

Hi!

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!

0 likes
5 replies
dimdot's avatar

Thanks! The 'distinct' rule did the job. I missed it when I read the documentation.

The thing now is that the validation errors sometimes don't show up in my view. The pattern seems random. I submit the form with the same validation errors on purpose and the errors sometimes show up and sometimes they don't.

@foreach ($errors->all() as $error)
    <div class="card-panel red white-text alert">
        <span>{{ $error }}</span>
    </div>
@endforeach 
thoasty's avatar

You might want to

Log::info($request->all())

to see if the validation really is the issue.

dimdot's avatar

With Log::info($request->all()) when $errors->all() returns an empty array there is nothing logged.

When $errors->all() contains the validation error messages, the following message is logged

production.ERROR: RuntimeException: The only supported ciphers are AES-128-CBC and AES-256-CBC with the correct key lengths. in vendor\laravel\framework\src\Illuminate\Encryption\Encrypter.php:43

thoasty's avatar

You seem to have made a couple of different mistakes then. You should check the rest of your code.

Please or to participate in this conversation.