Problem using Wizard in Custom Filament Page
Typed property Filament\Forms\Components\Component::$container must not be accessed before initialization
<?php
namespace App\Filament\Advisor\Pages;
use App\Models\Advisor;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Wizard;
use Filament\Forms\Concerns\InteractsWithForms;
use Filament\Forms\Form;
use Filament\Notifications\Notification;
use Filament\Pages\Page;
class ProfileInformation extends Page
{
use InteractsWithForms;
public ?array $data = [];
public Advisor $record;
protected static ?string $navigationIcon = 'heroicon-o-credit-card';
protected static string $view = 'filament.advisor.pages.profile-information';
public function mount(): void
{
$this->record = Advisor::findorFail(auth()->id());
$this->form->fill($this->record->attributesToArray());
}
public function form(Form $form): Form
{
return $form
->schema([
Wizard::make([
Wizard\Step::make('Info')
->schema([
TextInput::make('name'),
]),
]),
])
->statePath('data')
->model(Advisor::class);
}
public function save(): void
{
$data = $this->form->getState();
$this->record->update($data);
Notification::make()->success()->title('Saved')->send();
}
}
<?php
namespace App\Filament\Advisor\Pages;
use App\Models\Advisor;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Wizard;
use Filament\Forms\Concerns\InteractsWithForms;
use Filament\Forms\Form;
use Filament\Notifications\Notification;
use Filament\Pages\Page;
class ProfileInformation extends Page
{
use InteractsWithForms;
public ?array $data = [];
public Advisor $record;
protected static ?string $navigationIcon = 'heroicon-o-credit-card';
protected static string $view = 'filament.advisor.pages.profile-information';
public function mount(): void
{
$this->record = Advisor::findorFail(auth()->id());
$this->form->fill($this->record->attributesToArray());
}
public function form(Form $form): Form
{
return $form
->schema([
Wizard::make([
Wizard\Step::make('Info')
->schema([
TextInput::make('name'),
]),
]),
])
->statePath('data')
->model(Advisor::class);
}
public function save(): void
{
$data = $this->form->getState();
$this->record->update($data);
Notification::make()->success()->title('Saved')->send();
}
}
0 Replies