Livewire component for dependant and/or searchable select inputs

Overview

Livewire Select

Livewire component for dependant and/or searchable select inputs

Preview

preview

Installation

You can install the package via composer:

composer require asantibanez/livewire-select

Requirements

This package uses livewire/livewire (https://laravel-livewire.com/) under the hood.

It also uses TailwindCSS (https://tailwindcss.com/) for base styling.

Please make sure you include both of these dependencies before using this component.

Usage

In order to use this component, you must create a new Livewire component that extends from LivewireSelect

You can use make:livewire to create a new component. For example.

php artisan make:livewire CarModelSelect

In the CarModelSelect class, instead of extending from the base Livewire Component class, extend from LivewireSelect class. Also, remove the render method. You'll have a class similar to this snippet.

class CarModelSelect extends LivewireSelect
{
    //
}

In this class, you must override the following methods to provide options for your select input

public function options($searchTerm = null) : Collection 
{
    //
}

options() must return a collection of keyed values array items that must have at least the following keys: value and description. For example:

public function options($searchTerm = null) : Collection 
{
    return collect([
        [
            'value' => 'honda',
            'description' => 'Honda',
        ],
        [
            'value' => 'mazda',
            'description' => 'Mazda',
        ],
        [
            'value' => 'tesla',
            'description' => 'Tesla',
        ],       
    ]);
}

To render the component in a view, just use the Livewire tag or include syntax

<livewire:car-brand-select
   name="car_brand_id"
   :value="$initialValue" // optional
   placeholder="Choose a Car Brand" // optional
/>

You'll see on screen a select input with some custom styles with your defined values

preview

Nothing fancy there. Now, let's make another select input depend on its value.

Create another component following the same process above. In this case, we will create a CarModelSelect with the following options() method.

// In CarModelSelect component
public function options($searchTerm = null) : Collection 
{
    $modelsByBrand = [
        'tesla' => [
            ['value' => 'Model S', 'description' => 'Model S'],
            ['value' => 'Model 3', 'description' => 'Model 3'],
            ['value' => 'Model X', 'description' => 'Model X'],
        ],
        'honda' => [
            ['value' => 'CRV', 'description' => 'CRV'],
            ['value' => 'Pilot', 'description' => 'Pilot'],
        ],
        'mazda' => [
            ['value' => 'CX-3', 'description' => 'CX-3'],
            ['value' => 'CX-5', 'description' => 'CX-5'],
            ['value' => 'CX-9', 'description' => 'CX-9'],
        ],
    ];

    $carBrandId = $this->getDependingValue('car_brand_id');

    if ($this->hasDependency('car_brand_id') && $carBrandId != null) {
        return collect(data_get($modelsByBrand, $carBrandId, []));
    }

    return collect([
        ['value' => 'Model S', 'description' => 'Tesla - Model S'],
        ['value' => 'Model 3', 'description' => 'Tesla - Model 3'],
        ['value' => 'Model X', 'description' => 'Tesla - Model X'],
        ['value' => 'CRV', 'description' => 'Honda - CRV'],
        ['value' => 'Pilot', 'description' => 'Honda - Pilot'],
        ['value' => 'CX-3', 'description' => 'Mazda - CX-3'],
        ['value' => 'CX-5', 'description' => 'Mazda - CX-5'],
        ['value' => 'CX-9', 'description' => 'Mazda - CX-9'],
    ]);
} 

and define it in the view like this

<livewire:car-model-select
    name="car_model_id"
    placeholder="Choose a Car Model"
    :depends-on="['car_brand_id']"
/>

With these two snippets we have defined a select input that depends-on another select input with name car_brand_id. With this definition, we tell our component to listen to any updates on our car_brand_id input and be notified on changes.

preview

Notice in the options() method the use of two other helper methods: getDependingValue and hasDependency.

getDependingValue('token') will return the value of another field, in this case car_brand_id. If car_brand_id has no value, then it will return null.

hasDependency('token') allows us to check if our component has been specified to depend on other component values. This allows us to reuse the component by checking if a dependency has been specified in our layouts.

For example if we define the same component without the :depends-on attribute, we can use the component and return all car models.

<livewire:car-model-select
    name="car_model_id"
    placeholder="Choose a Car Model"
/>

It should look something like this

preview

Searchable inputs

You can define the searchable attribute on the component to change the behavior of your inputs. With :searchable="true" your component will change its behavior to allow searching the options returned in the options() method.

<livewire:car-model-select
   name="car_model_id"
   placeholder="Choose a Car Model"
   :searchable="true"
/>

Your input will look something like this

preview

To filter the options in the dropdown, you can use the $searchTerm parameter in the options() method.

Customizing the UI

// TODO 😬

Advanced behavior

// TODO 😬

AlpineJs support

Add AlpineJs for arrow-keys navigation, enter key for selection, enter/space keys for reset. 😎

Testing

composer test

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

Comments
  • Basic help - FatalError Declaration of Asantibanez\LivewireSelect\CarModelSelect::options():

    Basic help - FatalError Declaration of Asantibanez\LivewireSelect\CarModelSelect::options():

    Hello!

    This component looks like exactly what I need for my project however I am having trouble getting it working so can someone help me on what I am doing wrong?

    I have followed the guide in the readme using your example. Trying to create a searchable field however am getting this error:

    Symfony\Component\ErrorHandler\Error\FatalError Declaration of Asantibanez\LivewireSelect\CarModelSelect::options(): Asantibanez\LivewireSelect\Collection must be compatible with Asantibanez\LivewireSelect\LivewireSelect::options($searchTerm = NULL): Illuminate\Support\Collection

    Livewire\CarModelSelect.php

    <?php
    
    namespace App\Http\Livewire;
    
    use Livewire\Component;
    use Asantibanez\LivewireSelect\LivewireSelect;
    
    class CarModelSelect extends LivewireSelect
    {
          public function options($searchTerm = null) : Collection
          {
            return collect([
                [
                    'value' => 'honda',
                    'description' => 'Honda',
                ],
                [
                    'value' => 'mazda',
                    'description' => 'Mazda',
                ],
                [
                    'value' => 'tesla',
                    'description' => 'Tesla',
                ],
            ]);
          }
    }
    

    BladeFile.blade.php

    <livewire:car-model-select name="car_model_id" placeholder="Choose a Car Model" :searchable="true" />
    

    I even thought maybe I was doing something wrong with the search so tried a basic select: <livewire:car-model-select name="car_brand_id" /> However I still get the same erorr what am I doing wrong?

    I know it will be something silly maybe I just dont understand how this works - Thank you for your help!

    opened by nathanmay 2
  • Class

    Class "App\Http\Livewire\LivewireSelect" not found

    I followed your directions in the Readme and this is the error I get:

    Class "App\Http\Livewire\LivewireSelect" not found

    I'm certain it's an issue with the namespace or the use class thing, but I'm too new at this to know what to do with it. They're currently set to:

    namespace App\Http\Livewire;
    
    use Livewire\Component;
    

    Any help would be greatly appreciated.

    opened by protoapostoli 1
  • Add support for `multiple` attribute

    Add support for `multiple` attribute

    This PR adds the ability to select multiple values.

    By adding the multiple attribute on the component the select input turns into a multi-select dropdown.

    <livewire:car-model-select
        name="car_model_ids[]"
        placeholder="Choose a Car Model"
        :multiple="true"
    />
    

    Example: multiselect

    To include the required assets I've also made some small changes on the blade directives.

    • Updated directive livewireSelectScripts
    • Added directive livewireSelectStyles

    Both directives now supports options where you can set which assets should be loaded.

    ...
        @livewireSelectStyles 
        <!-- 
             loads all styles defined in Asantibanez\LivewireSelect\LivewireSelect->css.
             omit this directive completely if Livewire::styles() and tailwindcss is already included on the page
         -->
    </head>
    <body>
        ...
     
        @livewireSelectScripts(alpine, livewire-select-multiple) 
        <!-- loads only alpinejs, livewire-select-multiple and the default required livewire-select-->
    </body>
    </html>
    
    opened by bfiessinger 1
  • WIP: Maintain an id that can be linked by a label

    WIP: Maintain an id that can be linked by a label

    I couldn't find anywhere that the id {{ $name }}-selected was being used, so this shouldn't break anything. It's good for a label to still be able to reference the "input".

    opened by skeemer 1
  • Your requirements could not be resolved to an installable set of packages.

    Your requirements could not be resolved to an installable set of packages.

    Hi! I Started to learn Laravel. ISo maybe the quiestion is strange, but I can't isntall this package. I'm using Laravel 8.0

    Your requirements could not be resolved to an installable set of packages.

    Problem 1 - asantibanez/livewire-select[1.1.0, ..., 1.1.4] require illuminate/support ^6.0|^7.0 -> found illuminate/support[v6.0.0, ..., 6.x-dev, v7.0.0, ..., 7.x-dev] but it conflicts with your root composer.json require (^8.13). - Root composer.json requires asantibanez/livewire-select ^1.1 -> satisfiable by asantibanez/livewire-select[1.1.0, ..., 1.1.4].

    Installation failed, reverting ./composer.json and ./composer.lock to their original content.

    Could you please help? Thanx gergely

    opened by faxunil 1
  • keyboard events alpine.js errors in production but not development

    keyboard events alpine.js errors in production but not development

    When I search and you my keyboard up and down buttons. The browser console will throw errors on production with alpine.js and I cannot select item up and down with keyboard.

    However in development this does not happen.

    I suspect there are some difference between npm run dev and npm run prod that causes this issue.

    I am using the latest version of alpine.js currently. 8 July 2020.

    Hope it helps thank you

    opened by ziming 1
  • when searchable the 'drop down' does not work

    when searchable the 'drop down' does not work

    Hi

    in a view

    <livewire:country-select name="country_select" placeholder="Choose a country" :searchable="true" />
    

    component code:

    <?php
    
    namespace App\Http\Livewire;
    
    use App\Models\Country;
    use Asantibanez\LivewireSelect\LivewireSelect;
    use Illuminate\Support\Collection;
    
    class CountrySelect extends LivewireSelect
    {
        public function options($searchTerm = null): Collection
        {
            return Country::orderBy('name')->get(['id', 'name'])->mapWithKeys(function ($item, $key) {
                return [$key => [
                    'value' => $item->id,
                    'description' => $item->name
                ]];
            });
        }
    
        public function selectedOption($value)
        {
            $user = Country::find($value);
    
            return [
                'value' => $user->id,
                'description' => $user->name
            ];
        }
    }
    

    Result Screen Shot 2021-11-13 at 15 52 09

    opened by rabol 0
  • Hover highlight background colour to be same as active item

    Hover highlight background colour to be same as active item

    Currently when your mouse hover over over the search item dropdown. It is bg-gray-100. While at the same time the text is white (text-white).

    This makes it really hard to see.

    This PR try to fix that

    opened by ziming 0
  • Keyboard event errors

    Keyboard event errors

    Using searchable option, getting errors on keydown.arrow-down and keydown.enter events. On Chrome:

    Alpine Expression Error: Cannot read properties of undefined (reading 'length') Expression: "selectDown(window.livewire.find('JTuTirbOLoeINK9XhTum'))"

    Alpine Expression Error: Cannot read properties of undefined (reading 'length') Expression: "confirmSelection(window.livewire.find('JTuTirbOLoeINK9XhTum'))"

    On Firefox:

    Alpine Expression Error: component.data.optionsValues is undefined Expression: "selectDown(window.livewire.find('AIPnzW965NeyVlAjcTY9'))"

    Alpine Expression Error: component.data.optionsValues is undefined Expression: "confirmSelection(window.livewire.find('AIPnzW965NeyVlAjcTY9'))"

    Strangely, keydown.arrow-up works find, so I can use the keyboard to select options upward, but cannot select downwards or confirm selection by using keyboard, only mouse.

    Alpine v3.7.1 Livewire v2.10.1 livewire-select v2.1.0

    Thanks.

    opened by unarmedwombat 0
  • Is it possible to have a Custom

    Is it possible to have a Custom "the search-no-results.blade.php" content per instance?

    Is it possible to customize this for different uses in the website? For instance, I want to have the search-no-results.blade.php to show something different depending on what form it will be used on.

    opened by jphilapy 0
  • Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'version')

    Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'version')

    I have followed the guide in the readme using your example. Trying to create a searchable field however am getting this error: Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'version') at beforeAlpineTwoPointSevenPointThree (SupportAlpine.js:315) at isHiding (SupportAlpine.js:299) at alpinifyElementsForMorphdom (SupportAlpine.js:274) at onBeforeElUpdated (index.js:459) at callHook (morphdom.js:35) at morphEl (morphdom.js:199) at morphdom.js:332 at morphEl (morphdom.js:219) at morphdom.js:332 at morphEl (morphdom.js:219)

    Livewire

    <?php
    
    namespace App\Http\Livewire\Admin;
    
    use Livewire\Component;
    use Asantibanez\LivewireSelect\LivewireSelect;
    use Illuminate\Support\Collection;
    
    class SelectTab9 extends LivewireSelect
    {
        public function options($searchTerm = null) : Collection
        {
            return collect([
                ['value' => 'Model S', 'description' => 'Tesla - Model S'],
                ['value' => 'Model 3', 'description' => 'Tesla - Model 3'],
                ['value' => 'Model X', 'description' => 'Tesla - Model X'],
                ['value' => 'CRV', 'description' => 'Honda - CRV'],
                ['value' => 'Pilot', 'description' => 'Honda - Pilot'],
                ['value' => 'CX-3', 'description' => 'Mazda - CX-3'],
                ['value' => 'CX-5', 'description' => 'Mazda - CX-5'],
                ['value' => 'CX-9', 'description' => 'Mazda - CX-9'],
            ]);
        }
    }
    

    Blade

    <livewire:admin.select-tab9 name="car_brand_id" placeholder="Choose a Car Brand" :searchable="true"/>

    Thank you for your help!

    opened by alisanco 5
  • How to bind selected model instance (case editing model instance)

    How to bind selected model instance (case editing model instance)

    hi all,

    I have a model that have foreign id. I was able to create a model instance with foreign id value By using livewire-select. But when editing a model instance, my selected foreign model class can't displayed at form edit

    here is my model class:

    class MasterBarang extends Model
    {
          use HasFactory;
          use UserRelationship;
      
          protected $table = 'master_barang';
          protected $fillable = ['mtgkey', 'kode_perkiraan', 'nama_perkiraan', 'level', 'kode_khusus', 'tipe', 'satuan', 'created_user_id', 'updated_user_id'];
    }
    
    class SaldoAwal extends Model
    {
        use HasFactory;
        protected $table = 'saldo_awal';
        protected $fillable = [
            'unit_key',
            'nomor_bapnb',
            'nomor_spk',
            'tanggal',
            'kode_gudang',
            'kode_transaksi',
            'tanggal_verifikasi',
            'created_user_id',
            'updated_user_id'
        ];
    
        public function items()
        {
            return $this->hasMany(SaldoAwalItem::class);
        }
    }
    
    class SaldoAwalItem extends Model
    {
          use HasFactory;
          protected $table = 'saldo_awal_item';
          protected $fillable = [
              'saldo_awal_id',
              'unit_key',
              'nomor_bapnb',
              'master_barang_id',
              'jumlah',
              'harga',
              'total_harga',
              'id_satuan',
              'merek',
              'verified',
              'created_user_id',
              'updated_user_id'
          ];
      
          public function master_barang()
          {
              return $this->belongsTo(MasterBarang::class);
          }
    }
    

    here my livewire-select class

    class MasterBarangSelect extends LivewireSelect
    {
        public function options($searchTerm = null): Collection
        {
            if (null != $searchTerm) {
                return MasterBarang::where('nama_perkiraan', 'like', '%' . $searchTerm . '%')
                    ->take(10)
                    ->get(['id', 'nama_perkiraan'])->mapWithKeys(function ($item, $key) {
                        return [$key => [
                            'value' => $item->id,
                            'description' => $item->nama_perkiraan
                        ]];
                    });
            }
            return MasterBarang::latest()
                ->take(10)
                ->get(['id', 'nama_perkiraan'])
                ->mapWithKeys(function ($item, $key) {
                    return [$key => [
                        'value' => $item->id,
                        'description' => $item->nama_perkiraan
                    ]];
                });
        }
    
        public function selectedOption($value)
        {
            $master_barang = MasterBarang::find($value);
            return [
                'value' => $master_barang->id,
                'description' => $master_barang->nama_perkiraan
            ];
        }
    }
    

    here is my livewire class

    class SaldoAwalDetail extends Component
    {
        public $saldo_awal;
    
        public $master_barang_id;
        public $jumlah;
        public $harga;
        public $id_satuan;
        public $merek;
        public $showCreateSaldoAwalItemForm;
    
    
        public $saldoAwalItemBeingEdit;
        public $saldoAwalItemIdBeingEdit;
        public $showEditSaldoAwalItemForm;
        public $masterBarangIdEdit;
    
        protected $listeners = ['master_barang_idUpdated', 'master_barang_edit_idUpdated'];
    
        // capture master_barang_id from emit signal
        public function master_barang_idUpdated($data)
        {
            $this->master_barang_id = $data['value'];
        }
    
        public function master_barang_edit_idUpdated($data)
        {
            $this->masterBarangIdEdit = $data['value'];
        }
    
        public $rules = [
            'master_barang_id' => 'required',
            'jumlah' => 'required',
            'harga' => 'required',
            'id_satuan' => 'required',
            'merek' => 'required',
        ];
    
    
        public function mount($saldo_awal_id)
        {
            $this->saldo_awal = SaldoAwal::findOrFail($saldo_awal_id);
        }
    
        public function render()
        {
            $list_saldo_awal_item = SaldoAwalItem::where('saldo_awal_id', '=', $this->saldo_awal->id)->with('master_barang')->latest()->paginate(10);
            return view('livewire.saldo-awal.saldo-awal-detail', ['list_saldo_awal_item' => $list_saldo_awal_item]);
        }
    
        public function saldoAwalItemCreate()
        {
            // todo:
            // save form
            $this->validate();
            $item = SaldoAwalItem::create(array_merge(
                [
                    'master_barang_id' => $this->master_barang_id,
                    'jumlah' =>  $this->jumlah,
                    'harga' => $this->harga,
                    'id_satuan' => $this->id_satuan,
                    'merek' => $this->merek
                ],
                [
                    'saldo_awal_id' => $this->saldo_awal->id,
                    'unit_key' => config('persediaan.unit_key'),
                    'nomor_bapnb' => $this->saldo_awal->nomor_bapnb,
                    'total_harga' => $this->jumlah * $this->harga,
                    'created_user_id' => $this->user->id
                ]
            ));
            $this->resetInputForm();
            $this->showCreateSaldoAwalItemForm = false;
        }
    
        private function resetInputForm()
        {
            $this->master_barang_id = null;
            $this->jumlah = null;
            $this->harga = null;
            $this->id_satuan = null;
            $this->merek = null;
        }
    
        public function showEditForm($saldo_item_id)
        {
            $this->saldoAwalItemIdBeingEdit = $saldo_item_id;
            $this->saldoAwalItemBeingEdit = SaldoAwalItem::with('master_barang')->findOrFail($this->saldoAwalItemIdBeingEdit);
            $this->masterBarangIdEdit = $this->saldoAwalItemBeingEdit->master_barang_id;
            $this->showEditSaldoAwalItemForm = true;
        }
    
        public function showDeleteForm($saldo_item_id)
        {
        }
    
        public function getUserProperty()
        {
            return Auth::user();
        }
    }
    
    

    and here is my blade template

    <div>
        <x-jet-button wire:click="$set('showCreateSaldoAwalItemForm', true)" wire:loading.attr="disabled">
            {{ __('Input Rincian') }}
        </x-jet-button>
    
        <table class="items-center bg-transparent w-full border-collapse ">
            <thead>
                <tr>
                    <x-table-header>No. BAPNB</x-table-header>
                    <x-table-header>Master Barang</x-table-header>
                    <x-table-header>Merek</x-table-header>
                    <x-table-header>Jumlah</x-table-header>
                    <x-table-header>Harga</x-table-header>
                    <x-table-header>Total</x-table-header>
                    <x-table-header>Action</x-table-header>
                </tr>
            </thead>
    
            <tbody>
                @forelse ($list_saldo_awal_item as $saldo_item)
                    <tr>
                        <x-table-column>
                            {{ $saldo_item->nomor_bapnb }}
                        </x-table-column>
                        <x-table-column>
                            {{ $saldo_item->master_barang->nama_perkiraan }}
                        </x-table-column>
                        <x-table-column>
                            {{ $saldo_item->merek }}
                        </x-table-column>
                        <x-table-column>
                            {{ $saldo_item->jumlah }}
                        </x-table-column>
                        <x-table-column>
                            {{ $saldo_item->harga }}
                        </x-table-column>
                        <x-table-column>
                            {{ $saldo_item->total_harga }}
                        </x-table-column>
                        <x-table-column>
                            <button class="cursor-pointer ml-6 text-sm text-gray-400 underline" wire:click="showEditForm({{ $saldo_item->id }})">
                                edit
                            </button>
                            <button class="cursor-pointer ml-6 text-sm text-red-500 underline" wire:click="showDeleteForm({{ $saldo_item->id }})">
                                Hapus
                            </button>
                        </x-table-column>
                    </tr>
                @empty
                    <x-table-column colspan="4">
                        Data Tidak tersedia
                    </x-table-column>
                @endforelse                    
            </tbody>
        </table>
        <div>
            {{ $list_saldo_awal_item->links() }}
        </div>
    
        <x-jet-dialog-modal wire:model="showEditSaldoAwalItemForm">
            <x-slot name="title">
                {{ __('Edit Rincian Saldo Awal') }}
            </x-slot>
            <x-slot name="content">            
                <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
                    <div>
                        <x-jet-label for="master_barang_id" value="{{ __('Master Barang') }}" />
                        <livewire:master-barang-select 
                            :value="$masterBarangIdEdit" 
                            name="master_barang_edit_id" 
                            :selectView="livewire-select::search-selected-option"
                            />
                    </div>
                </div>
            </x-slot>
            <x-slot name="footer">
                <x-jet-secondary-button wire:click="$set('showEditSaldoAwalItemForm', false)" wire:loading.attr="disabled">
                    {{ __('Cancel') }}
                </x-jet-secondary-button>
                {{--
                <x-jet-button class="ml-2" wire:click="saldoAwalItemCreate" wire:loading.attr="disabled">
                    {{ __('Save') }}
                </x-jet-button> --}}
            </x-slot>
        </x-jet-dialog-modal>
    
        <x-jet-dialog-modal wire:model="showCreateSaldoAwalItemForm">
            <x-slot name="title">
                {{ __('Input Rincian Saldo Awal') }}
            </x-slot>
            <x-slot name="content">            
                <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
                    <div>
                        <x-jet-label for="master_barang_id" value="{{ __('Master Barang') }}" />
                        <livewire:master-barang-select name="master_barang_id" id="master_barang_id"  name="master_barang_id" placeholder="Choose barang" :searchable="true" />
                    </div>
                    <div>
                        <x-jet-label for="jumlah" value="{{ __('Jumlah') }}" />
                        <x-jet-input id="jumlah" class="block mt-1 w-full" type="text" 
                        wire:model.defer="jumlah"
                        name="jumlah" />
                    </div>
                    <div>
                        <x-jet-label for="harga" value="{{ __('Harga') }}" />
                        <x-jet-input id="harga" class="block mt-1 w-full" type="text" 
                            wire:model.defer="harga"
                            name="harga"  />
                    </div>
                    <div>
                        <x-jet-label for="id_satuan" value="{{ __('Satuan') }}" />
                        <x-jet-input id="id_satuan" class="block mt-1 w-full" type="text" 
                            wire:model.defer="id_satuan"
                            name="id_satuan"  />
                    </div>
                    <div>
                        <x-jet-label for="merek" value="{{ __('Merek') }}" />
                        <x-jet-input id="merek" class="block mt-1 w-full" type="text" 
                            wire:model.defer="merek"
                            name="merek"  />
                    </div>
                </div>            
            </x-slot>
            <x-slot name="footer">
                <x-jet-secondary-button wire:click="$set('showCreateSaldoAwalItemForm', false)" wire:loading.attr="disabled">
                    {{ __('Cancel') }}
                </x-jet-secondary-button>
    
                <x-jet-button class="ml-2" wire:click="saldoAwalItemCreate" wire:loading.attr="disabled">
                    {{ __('Save') }}
                </x-jet-button>
            </x-slot>
        </x-jet-dialog-modal>
    </div>
    

    Any suggestion ? thanks

    opened by heru 0
  • fix cascading livewire select inputs nulled after repainting

    fix cascading livewire select inputs nulled after repainting

    The Problem:

    As mentioned in #18 currently while executing the render method all livewire-select component values, which have dependencies, are nulled.

    Assuming the following components the car-brand-select would indeed show up with the right (visible) value, but car-model-select would not only have no value, but it would also have no options (because car-brand-select value is actually null)

    <livewire:car-brand-select
       name="car_brand_id"
       :value="$initialValue" // optional
       placeholder="Choose a Car Brand" // optional
    />
    
    <livewire:car-model-select
        name="car_model_id"
        placeholder="Choose a Car Model"
        :depends-on="['car_brand_id']"
    />
    

    Solution:

    I have added a new property to the livewire component, called initValueEncoded, this value is set on mount the same as the value prop, but json encoded.

    why json? Refering to another pull request of mine (#37), it is mandatory that also an array of values can be submitted.

    Inside the select.blade.json the value Livewire property can now be set during component initialization:

    <div x-init="$wire.set('value', {{ $initValueEncoded }})">
    

    (closes #18)

    opened by bfiessinger 0
Releases(v2.1.0)
Owner
Andrés Santibáñez
Andrés Santibáñez
Example of using TALL stack to select country phone code.

Select country phone code using TALL stack About Example of using TALL stack to select country phone code. Each item represents a country. Each item h

Fernando Chagas 3 Jul 27, 2022
A bookmarkable, searchable cheatsheet for all of Laravel's default Artisan commands.

artisan.page A bookmarkable, searchable cheatsheet for all of Laravel's default Artisan commands. Generation The generation of the manifest files is d

James Brooks 284 Dec 25, 2022
Laravel-comments-livewire - Livewire components for the laravel-comments package

Associate comments and reactions with Eloquent models This package contains Livewire components to be used with the spatie/laravel-comments package. S

Spatie 15 Jan 18, 2022
Laravel Livewire form component with declarative Bootstrap 5 fields and buttons.

Laravel Livewire Forms Laravel Livewire form component with declarative Bootstrap 5 fields and buttons. Requirements Bootstrap 5 Installation composer

null 49 Oct 29, 2022
Laravel Livewire full page component routing.

Laravel Livewire Routes Laravel Livewire full page component routing. This package allows you to specify routes directly inside your full page Livewir

null 22 Oct 6, 2022
Livewire component that provides you with a modal that supports multiple child modals while maintaining state.

About LivewireUI Modal LivewireUI Modal is a Livewire component that provides you with a modal that supports multiple child modals while maintaining s

Livewire UI 806 Jan 6, 2023
Livewire component that brings Spotlight/Alfred-like functionality to your Laravel application.

About LivewireUI Spotlight LivewireUI Spotlight is a Livewire component that provides Spotlight/Alfred-like functionality to your Laravel application.

Livewire UI 792 Jan 3, 2023
Laravel Livewire component to show Events in a good looking monthly calendar

Livewire Calendar This package allows you to build a Livewire monthly calendar grid to show events for each day. Events can be loaded from within the

Andrés Santibáñez 680 Jan 4, 2023
Livewire component that provides you with a modal that supports multiple child modals while maintaining state.

About Wire Elements Modal Wire Elements Modal is a Livewire component that provides you with a modal that supports multiple child modals while maintai

Wire Elements 806 Jan 6, 2023
Livewire component that brings Spotlight/Alfred-like functionality to your Laravel application.

About Wire Elements Spotlight Wire Elements Spotlight is a Livewire component that provides Spotlight/Alfred-like functionality to your Laravel applic

Wire Elements 790 Dec 27, 2022
A dynamic table component for Laravel Livewire - For Slack access, visit:

A dynamic Laravel Livewire component for data tables. Bootstrap 4 Demo | Bootstrap 5 Demo | Tailwind Demo | Demo Repository Installation You can insta

Anthony Rappa 1.3k Jan 1, 2023
A dynamic Laravel Livewire component for multi steps form

Livewire component that provides you with a wizard that supports multiple steps form while maintaining state.

Vildan Bina 233 Jan 4, 2023
An advanced datatable component for Laravel Livewire.

Livewire Smart Table An advanced, dynamic datatable component with pagination, sorting, and searching including json data. Installation You can instal

Turan Karatuğ 87 Oct 13, 2022
Render a Livewire component on a specific target in the DOM.

Livewire Portals Render a Livewire component on a specific target in the DOM. Install THIS PACKAGE IS STILL IN DEVELOPMENT, TO USE, PLEASE ADD THE FOL

Jeff Ochoa 20 Aug 11, 2022
This package allows you to render livewire components like a blade component, giving it attributes, slots etc

X-livewire This package allows you to render livewire components like a blade component, giving it attributes, slots etc. Assuming you wanted to creat

null 7 Nov 15, 2022
A Laravel 8 and Livewire 2 demo showing how to search and filter by tags, showing article and video counts for each tag (Polymorphic relationship)

Advanced search and filter with Laravel and Livewire A demo app using Laravel 8 and Livewire 2 showing how to implement a list of articles and tags, v

Sérgio Jardim 19 Aug 29, 2022
Laravel blade directives and php helpers for serverside rendered content, based on browser window size WITHOUT css. Requires Livewire and AlpineJS.

Laravel Livewire Window Size and Breakpoints Laravel blade directives and php helpers for server side rendered content, based on browser window size W

Tina Hammar 15 Oct 6, 2022
Sweetalert and Toaster notifications for Laravel livewire with support for tailwind and bootstrap.

Larabell Integrate livewire with sweetalert. Installation How to use Sweetalert Toast Available configuration Installation composer require simtabi/la

Simtabi 3 Jul 27, 2022
Project with laravel 9 and livewire login and register + edit user profile

Laravel 9 has just been released, and I decided to make a prototype project with Laravel 9 + livewire. In this project, full user registration with mobile number along with profile editing has been implemented. Project features are as follows

ali ahmadi 5 Nov 14, 2022