Skip to content

Commit

Permalink
disabled empty selects
Browse files Browse the repository at this point in the history
  • Loading branch information
daguilarm committed May 10, 2021
1 parent 20a7a9e commit c368a2f
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion resources/views/type/select.blade.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
@unless (Combobox::value($element, 'hideOnEmpty') === true && Combobox::count($element, 'options') === 0)
@php
$totalOptions = Combobox::count($element, 'options');
@endphp

@unless (Combobox::value($element, 'hideOnEmpty') === true && $totalOptions === 0)
{{-- Field main container --}}
<div
id="field-container-for-{{ Combobox::value($element, 'uriKey') }}"
Expand All @@ -19,6 +23,11 @@ class="{{ Combobox::value($element, 'labelCss') ?? 'block w-full text-sm font-me
name="{{ $element?->label ?? $element['uriKey'] }}"
class="{{ Combobox::value($element, 'fieldCss') ?? 'bg-white w-full relative border border-gray-300 rounded-md shadow-sm pl-3 pr-10 py-2 mt-1 text-left cursor-default focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm' }}"

{{-- Disable empty elements --}}
@if($totalOptions <= 0)
disabled
@endif

{{-- Last element or element without Livewire Response --}}
@unless (Combobox::value($element, 'withoutResponse'))
wire:model.defer="comboboxValues.{{ Combobox::value($element, 'uriKey') }}"
Expand Down

0 comments on commit c368a2f

Please sign in to comment.