Support the ongoing development of Laravel.io →
Requests Forms Validation
Last updated 1 year ago.
0

I doubt that such tutorial exist, it is a bit too specific.

What exactly do you mean by dynamic? If you can explain in more detail what you want to achieve people might help you get in the right direction.

0

I have form where I can add another textfield with jquery. So when I submit the form there can be 10 textfields or 1 or 5, depends on the user. The textfields are dynamically added. my problem is that when the validation fail I don't know how to populate the form with these dynamically added fields again, so the user wouldn't have to add them again.

0

If the name of the fields are something like field[], you will end up with an array of the fields in Laravel. If the validation fails and you return the user to the form you should be able to re-add the fields by doing something like this:

@foreach (old('field') as $field)
    <input name="field[]" value="{{ $field }}">
@endforeach

You might also consider using ajax. That way the form would never have to be rebuilt anyway.

Last updated 8 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Itachicz11 itachicz11 Joined 12 Jul 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.