Skip to content

Commit

Permalink
validation
Browse files Browse the repository at this point in the history
Signed-off-by: Ritesh Singh <[email protected]>
  • Loading branch information
riteshsingh1 committed May 6, 2021
1 parent ec3973e commit 6f1953c
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 21 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "imritesh/livecrud",
"description": "Generate Basic Crud Operations With Livewire and Tailwind Css For Laravel",
"license": "MIT",
"version": "v2.1.1",
"version": "v2.1.2",
"authors": [
{
"name": "Ritesh Singh",
Expand Down
12 changes: 11 additions & 1 deletion src/Commands/LiveCrudView.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,17 @@ public function makeInput($name)
$type = $this->getType($name);
$label = ucfirst(str_replace('-', ' ', Str::slug($name)));
$message = '{{ $message }}';
return "<div><label class='block'><span class='text-gray-700 @error('{$name}') text-red-500 @enderror'>{$label}</span><input type='{$type}' class='mt-1 block w-full rounded-md border-gray-300 shadow-sm @error('{$name}') border-red-500 @enderror focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50' wire:model='{$name}'>@error('{$name}')<span class='text-red-500 text-sm'>{$message}</span>@enderror</label></div>";
if(config('livecrud.template') == 'tailwind')
{
return "<div><label class='block'><span class='text-gray-700 @error('{$name}') text-red-500 @enderror'>{$label}</span><input type='{$type}' class='mt-1 block w-full rounded-md border-gray-300 shadow-sm @error('{$name}') border-red-500 @enderror focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50' wire:model='{$name}'>@error('{$name}')<span class='text-red-500 text-sm'>{$message}</span>@enderror</label></div>";
}
if(config('livecrud.template') == 'bootstrap')
{
return "<div class='form-group'><label for='{$name}'>{$label}</label><input type='{$type}' class='form-control @error('{$name}') is-invalid @enderror' wire:model='{$name}'>@error('{$name}')<div class='invalid-feedback'>{$message}</div>@enderror</div>";

}


}

public function getType($name)
Expand Down
37 changes: 18 additions & 19 deletions src/stubs/bootstrap.view.php.stub
Original file line number Diff line number Diff line change
Expand Up @@ -83,25 +83,24 @@


{{-- create / edit form --}}
<div wire:ignore>
<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel"> {{ $mode == 'create' ? 'Add New Record' : 'Update Record ' }}</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
{{ form }}
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="button" @if($mode == 'create') wire:click="store()" @else wire:click="update()" @endif class="btn btn-primary">
{{ $mode == 'create' ? 'Save Record' : 'Update Record' }}
</button>
</div>

<div class="modal fade" wire:ignore.self id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel"> {{ $mode == 'create' ? 'Add New Record' : 'Update Record ' }}</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
{{ form }}
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="button" @if($mode == 'create') wire:click="store()" @else wire:click="update()" @endif class="btn btn-primary">
{{ $mode == 'create' ? 'Save Record' : 'Update Record' }}
</button>
</div>
</div>
</div>
Expand Down

0 comments on commit 6f1953c

Please sign in to comment.