laravel: Input array forms for multiple entries. How to ignore not filled entries after submitting -


i have page shows 4 empty entries in single form. following basic form html code. have lables , validation code added each input not showing keep things simple.

<form> <!-- entry 1 -->     <input type="text" class="form-control" placeholder="level" name="levels[level][]">     <input type="text" class="form-control" placeholder="time" name="levels[build_time][]">  <!-- entry 2 -->     <input type="text" class="form-control" placeholder="level" name="levels[level][]">     <input type="text" class="form-control" placeholder="time" name="levels[build_time][]">  <!-- entry 3 -->     <input type="text" class="form-control" placeholder="level" name="levels[level][]">     <input type="text" class="form-control" placeholder="time" name="levels[build_time][]">  <!-- entry 4 -->     <input type="text" class="form-control" placeholder="level" name="levels[level][]">     <input type="text" class="form-control" placeholder="time" name="levels[build_time][]">  <button type="submit" class="btn btn-primary">submit</button> </form> 

the user need not enter entries. enter based on requirement (1 or more)

i used work on django. there formset take care if submit empty forms.

in each entry have validation rules both of them cannot empty

    $this->validate($request, [         'levels.level.*' => 'required',         'levels.build_time.*' => 'required',     ]); 

so fill 2 entries , leave other 2 entries empty , submit, shows validation errors empty forms.

so how in laravel.


Comments

Popular posts from this blog

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -