I'm trying to use a full-page livewire component along with a Filament form. I'd like it to update the database automatically after a user selects from the dropdown, so I'm using live().
The call is made in the network tab in dev tools to livewire/update, but the field isn't updated in the database.
I've tried following the docs, but it seems to indicate this all happens seamlessly without having to have like a submit method or anything. Perhaps I'm misunderstanding.
What is the process for creating form on a full-page livewire component, preferrably one that updates without clicking a submit button?
Here's my component:
<?php
class Config extends Page implements HasForms
{
use InteractsWithForms;
protected static ?string $title = 'Config';
protected static ?string $navigationIcon = 'heroicon-o-cog-8-tooth';
protected static string $view = 'filament.app.pages.location.config';
protected static ?string $slug = 'location/{location}/config';
protected static bool $shouldRegisterNavigation = false;
public Location $location;
public array $accounts = [];
public array $data = [];
public function mount(Location $location)
{
$this->location = $location->load('config');
if (empty($this->location->config)) {
$this->location->config()->create();
$this->location = $location->load('config');
}
$this->getAccounts();
$this->form->fill(['field_id' => $this->location->config->field_id]);
}
public function form(Form $form): Form
{
return $form
->schema([
FieldSet::make()->relationship('config')->schema([
Select::make('field_id')->label('Account Mapping')
->options($this->accounts)
->preload()
->searchable()
->live()
->loadingMessage('Loading accounts...'),
]),
])->statePath('data')
->model($this->location);
}
}
and here's the view file:
<x-filament::page>
{{ $this->form }}
</x-filament::page>