josedaian / select2wire
Select2 for livewire components.
Installs: 66
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 1
Open Issues: 0
Language:Blade
Type:package
Requires
- php: >=8.1
- livewire/livewire: >=3.0
Requires (Dev)
- livewire/livewire: ^3.0
- orchestra/testbench: ^6.0
- phpunit/phpunit: ^9.0
README
Laravel package for handling Select2 inputs for Livewire components.
Requirements
Quick Installation
composer require josedaian/select2wire
For Livewire 2.x version, go here: select2wire v1.x
Usage
Add the following line within your blade view, below the select2.js and jquery.js scripts
@select2wireScript
Within your Livewire component class, call the trait to do one of the functions when loading the component.
use Livewire\Component; use JoseDaian\Select2\Traits\HasSelect2Wire; class ExampleComponent extends Component { use HasSelect2Wire; }
If you don’t have a custom init event, you can call the initSelect2
event directly within your component view.
<div wire:init="initSelect2"> ... <!-- All your selects here --> </div>
Or in case you already have an init event inside your component, just add the following line
public function customInitFunction() { // your code $this->initSelect2(); }
And within your blade view, you’ll need to add the data-select2wire="select2"
attribute to your inputs select.
<select data-select2wire="select2"> <!-- options --> </select>
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email josedaian.cabrera@gmail.com instead of using the issue tracker.
Credits
Acknowledgments
This package was inspired by livewire-select2.
License
The MIT License (MIT). Please see License File for more information.