Persisting Model Data between Form Updates

I'm using the mount method to load extra data attributes to my model to present on the form in a View component. When I trigger a form input to become visible the model refreshes and I lose my extra data. Is there a way to stop the model from being refreshed or is there another method I could use to re-inject my data attributes?
public function mount(): void
{
$this->record = new Model();
$this->record->fillPersonalInfo();

$this->form->fill($this->record->toArray());
}

public function form(Form $form): Form
{
return $form->schema([
Section::make('')->schema([
\Filament\Forms\Components\View::make('personal')
->view('application/fiPersonalInfo', ['eops' => $this->record])
]),
...
])->statePath('data')->model($this->record);
}
public function mount(): void
{
$this->record = new Model();
$this->record->fillPersonalInfo();

$this->form->fill($this->record->toArray());
}

public function form(Form $form): Form
{
return $form->schema([
Section::make('')->schema([
\Filament\Forms\Components\View::make('personal')
->view('application/fiPersonalInfo', ['eops' => $this->record])
]),
...
])->statePath('data')->model($this->record);
}
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server