mardi 3 mai 2016

Form array validation Laravel 5.2

I am currently stuck on solving this problem. I am new to Laravel and the MVC framework. I am struggling to create the dynamic form that gives the user the ability to add as many forms as possible. When the user enters the page at first it generates 5 form fields . Here is a look at my code so far.

<div id = >


  <div  class="form-group col-md-6">


                  <div  class="col-md-6   form-group">

                        <label for=>Address</label>
                        <input type="text" name = "address[]" class="form-control" id= placeholder="Street Address"> <!-- problem form array how does this work in laravel --> 


                </div>


                  <div  class="form-group col-md-6">

                         <label for=>City</label>
                         <input type="text" value = "" class="form-control" id= placeholder="City">

                            @if ($errors->has('city'))
                                <span class="help-block">
                                    <strong></strong>
                                </span>
                            @endif
              </div>

How would I go about validating a form in Laravel 5.2 with from array

here's my controller

  public function Postdata(Request $request) { 

             $this->validate($request->all(), [
                'address.*' => 'required|string',
               'city' => 'required',
                  ]);

               }

I am using a for loop to generate the forms dynamically.

Can someone please help or point me in the right direction thank you !



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1WG7WUP
via IFTTT

Aucun commentaire:

Enregistrer un commentaire