F
Filamentβ€’4mo ago
gladjanus43

Select in custom livewire component with searchable removes wire.model

HI, I have a very weird issue. I have a custom livewire form in a modal. Everything is working really well except when I add the searchable to the select
Select::make('company_id')
->relationship('company', 'name')
->searchable()
->required(),
Select::make('company_id')
->relationship('company', 'name')
->searchable()
->required(),
Which results in html generated like this: <select x-ref="input" class="h-9 w-full rounded-lg border-none bg-transparent !bg-none choices__input" id="data.company_id" hidden="" tabindex="-1" data-choice="active"></select> However when I remove the searchable method it does add the wire.model to the select input. <select class .... wire:model="data.company_id"> When the searchable is removed everything works as you would expect, and loading the value from the database into the form. With the searchable it of course stays empty and gives the error Livewire Entangle Error: Livewire property ['data.company_id'] cannot be found on component: ['app.filament.pages.planning'] Anybody has seen this before? Or is there something i am missing? Help would be appreciated!
Solution:
Thanks anyway, reduced this to this public function editAction(): Action { return Action::make('Edit') ->requiresConfirmation()...
No description
Jump to solution
9 Replies
LeandroFerreira
LeandroFerreiraβ€’4mo ago
Are you using a statePath()? Did you add $this->form->fill() in the mount method?
gladjanus43
gladjanus43β€’4mo ago
I dont have the mount method. I am using a trait which renders the popup and initializes the form. When the record is clicked I call this code:
public function recordClicked(int $recordId): void
{
$this->modelInstance = $this->model::find($recordId);
$this->form->fill($this->modelInstance->toArray());
$this->dispatch('open-modal', id: 'weekview-modal');
}
public function recordClicked(int $recordId): void
{
$this->modelInstance = $this->model::find($recordId);
$this->form->fill($this->modelInstance->toArray());
$this->dispatch('open-modal', id: 'weekview-modal');
}
Do i still need to call this->form->fill on mount?
gladjanus43
gladjanus43β€’4mo ago
I am calling the recordClicked method when the item is clicked. That is where the id of the model is passed. How would it work to mount it?
No description
gladjanus43
gladjanus43β€’4mo ago
Because I dont think it is the correct way by adding the dialog to every item πŸ˜›
gladjanus43
gladjanus43β€’4mo ago
Yep you are totally right. Dont know why I went on the path of completly building the modal with a custom component....
Solution
gladjanus43
gladjanus43β€’4mo ago
Thanks anyway, reduced this to this public function editAction(): Action { return Action::make('Edit') ->requiresConfirmation() ->action(function (array $arguments) { dd($arguments); // $post = Post::find($arguments['post']); }); } 🀣
No description
LeandroFerreira
LeandroFerreiraβ€’4mo ago
exactly πŸ˜…
Want results from more Discord servers?
Add your server