FilamentF
Filamentβ€’2y ago
Clement

Select Multiple always active

Hi, I have my filament select rendered also when I goes into the modal, he will be always active by default and when I click outside the select component it still showing active hmm.
If I make it not multiple it work perfectly. Using Google Chrome.

My code
<?php

namespace App\Livewire\Metier;

use App\Models\TeamMetier;
use Filament\Forms\Components\Grid;
use Filament\Forms\Components\Select;
use Filament\Forms\Concerns\InteractsWithForms;
use Filament\Forms\Contracts\HasForms;
use Filament\Forms\Form;
use Illuminate\Support\Collection;
use Livewire\Component;

class ShowMetier extends Component implements HasForms
{
    use InteractsWithForms;

    public TeamMetier $metier;
    public $showDropdown = false;
    public $manageMetier = false;
    public ?array $data = [];

    public function mount(): void
    {
        $this->form->fill($this->data);
    }
    public function toggleDropdown()
    {
        $this->showDropdown = !$this->showDropdown;
    }

    public function form(Form $form): Form
    {
        return $form
            ->schema([
                Select::make('users')
                    ->multiple()
                    ->options(
                        $this->metier->team->users()->whereDoesntHave('teamMetiers', function ($subQuery) {
                            $subQuery->where('metier_id', $this->metier->id);
                        })->get()->pluck('name', 'id')
                    )
                    ->searchable()
            ])
            ->statePath('data');
    }

    public function create(): void
    {
        $form = $this->form->getState();
        
        foreach ($form['users'] as $user) {
            $this->metier->users()->attach($this->metier->id, ['user_id' => $user]);
        }

        $this->dispatch('refreshTable');
    }

    public function render()
    {
        return view('livewire.metier.show-metier');
    }
}


And a video πŸ™‚
filament_error-2.gif
Was this page helpful?