PHP code example of amabk / livewire-search-select
1. Go to this page and download the library: Download amabk/livewire-search-select library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
amabk / livewire-search-select example snippets
class UserForm extends Component
{
public $selectedUserIds = [];
#[On('usersSelected')]
// single: receives id or '' when cleared
// multi: receives array<int> of ids
public function usersSelected($userIds)
{
$this->selectedUserIds = $userIds;
}
public function render()
{
return view('livewire.user-form');
}
}
// Parent Component (UserForm.php)
public $userIds = [];
protected $listeners = ['userSelected'];
public function userSelected($userIds)
{
$this->userIds = $userIds;
}