Skip to content

Commit

Permalink
Better select
Browse files Browse the repository at this point in the history
  • Loading branch information
stanislawfortonski committed Jan 29, 2021
1 parent ca35e67 commit 3ad5751
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 24 deletions.
14 changes: 7 additions & 7 deletions resources/views/admin/posts/save.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,6 @@
</div>
@endempty

<div class="form-group">
<div class="custom-control custom-checkbox">
<input type="checkbox" class="custom-control-input" id="is_visible" name="is_visible" @if(!empty($post->is_visible) && $post->is_visible) checked @endif>
<label class="custom-control-label" for="is_visible">{{ __('visible') }}</label>
</div>
</div>

<div class="form-group">
@empty($post)
<x-select-categories />
Expand Down Expand Up @@ -123,6 +116,13 @@
@enderror
</div>

<div class="form-group">
<div class="custom-control custom-checkbox">
<input type="checkbox" class="custom-control-input" id="is_visible" name="is_visible" @if(!empty($post->is_visible) && $post->is_visible) checked @endif>
<label class="custom-control-label" for="is_visible">{{ __('visible') }}</label>
</div>
</div>

<div class="form-group">
<button type="submit" class="btn btn-primary">{{ $prefix }}</button>
</div>
Expand Down
38 changes: 21 additions & 17 deletions resources/views/components/inputs/select.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,25 @@
<label for="{{ $name }}">{{ __($label) }}</label>
@endif
<div class="input-group">
@foreach($options as $key => $val)
@php $find = false; @endphp
@if(is_array($value))
@foreach($value as $checked)
@if($checked == $key)
@php $find = true; @endphp
@endif
@endforeach
@endif
<div class="custom-control custom-checkbox d-inline m-1">
<input type="checkbox" class="custom-control-input" id="{{ $name.'_'.$key }}" name="{{ $name }}[]" value="{{ $key }}" @if($find) checked @endif>
<label class="custom-control-label" for="{{ $name.'_'.$key }}">{{ $val }}</label>
</div>
@endforeach
@error($name)
<small class="text-danger form-text">{{ $message }}</small>
@enderror
<ul class="list-unstyled">
@foreach($options as $key => $val)
@php $find = false; @endphp
@if(is_array($value))
@foreach($value as $checked)
@if($checked == $key)
@php $find = true; @endphp
@endif
@endforeach
@endif
<li>
<div class="custom-control custom-checkbox d-inline m-1">
<input type="checkbox" class="custom-control-input" id="{{ $name.'_'.$key }}" name="{{ $name }}[]" value="{{ $key }}" @if($find) checked @endif>
<label class="custom-control-label" for="{{ $name.'_'.$key }}">{{ $val }}</label>
</div>
</li>
@endforeach
@error($name)
<small class="text-danger form-text">{{ $message }}</small>
@enderror
</ul>
</div>

0 comments on commit 3ad5751

Please sign in to comment.