Skip to content

Instantly share code, notes, and snippets.

@webdevmatics
Created October 19, 2020 16:50
Show Gist options
  • Save webdevmatics/52a5c2be01ac58af58a04608a6273207 to your computer and use it in GitHub Desktop.
Save webdevmatics/52a5c2be01ac58af58a04608a6273207 to your computer and use it in GitHub Desktop.
CloneForm #livewire
<div>
<div>
@if (session()->has('message'))
<div class="alert alert-success">
{{ session('message') }}
</div>
@endif
</div>
<form wire:submit.prevent="store">
@csrf
@for($i=0; $i< count($inputs) ; $i++)
<h3>Education {{$i+1}} </h3>
<div class="form-section">
<input type="text" wire:model.lazy='inputs.{{$i}}.school_name' placeholder='school name'>
@error("inputs.{$i}.school_name")
<span class="error text-danger">Name required</span>
@endError
<br>
<input type="text" wire:model.lazy='inputs.{{$i}}.degree' placeholder='degree'>
<br>
<input type="text" wire:model.lazy='inputs.{{$i}}.field_of_study' placeholder='faculty'>
<br>
<input type="date" wire:model.lazy='inputs.{{$i}}.graduation_start_date'>
<br>
<input type="date" wire:model.lazy='inputs.{{$i}}.graduation_end_date'>
<br>
<button wire:click='remove({{$i}})' type="button" class=" btn btn-sm btn-danger m-2">-</button>
</div>
@endfor
<button wire:click="addNew" type="button" class=" btn btn-sm btn-primary mt-3">Add New</button>
<br>
<input type="submit" class="btn btn-success mt-4" value="Save Education">
</form>
</div>
<div>
<div>
@if (session()->has('message'))
<div class="alert alert-success">
{{ session('message') }}
</div>
@endif
</div>
<form wire:submit.prevent="store">
@csrf
@for($i=0; $i< count($inputs) ; $i++)
<h3>Education {{$i+1}} </h3>
<div class="form-section">
<input type="text" wire:model.lazy='inputs.{{$i}}.school_name' placeholder='school name'>
@error("inputs.{$i}.school_name")
<span class="error text-danger">Name required</span>
@endError
<br>
<input type="text" wire:model.lazy='inputs.{{$i}}.degree' placeholder='degree'>
<br>
<input type="text" wire:model.lazy='inputs.{{$i}}.field_of_study' placeholder='faculty'>
<br>
<input type="date" wire:model.lazy='inputs.{{$i}}.graduation_start_date'>
<br>
<input type="date" wire:model.lazy='inputs.{{$i}}.graduation_end_date'>
<br>
<button wire:click='remove({{$i}})' type="button" class=" btn btn-sm btn-danger m-2">-</button>
</div>
@endfor
<button wire:click="addNew" type="button" class=" btn btn-sm btn-primary mt-3">Add New</button>
<br>
<input type="submit" class="btn btn-success mt-4" value="Save Education">
</form>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment