Custom page with a wizard form

Ok only started using Filament this week, so forgive me if I'm missing something very basic. I'm trying to create a custom page with a wizard form component. I've got that working but when I try to add a select to the first page of the wizard based on a relationship in the model I get an error message
Call to a member function isRelation() on null
Call to a member function isRelation() on null
Solution:
The $model property is only (I think) used on Resources. If you're creating a custom page that interacts with a single record, you need a way to bind it to a specific record, so you need to set ->model() on the form itself
Jump to solution
4 Replies
Bardolf#6969
Bardolf#69692w ago
This is my custom page as it stands
class RegistrationWizard extends Page implements HasForms
{
use InteractsWithForms;

protected static ?string $model = User::class;

protected static ?string $navigationIcon = 'heroicon-o-document-text';

protected static string $view = 'filament.pages.registration-wizard';

public $is_partner_student = false;

public function mount()
{
$this->form->fill();
}

public function form(Form $form): Form
{
return $form
->schema([
Wizard::make([
Wizard\Step::make('Degree Information')
->schema([
Radio::make('is_partner_student')
->label('Were you referred by one of our partners?')
->inline()
->boolean()
->live(),
Select::make('partner')
->hidden(fn (Get $get): bool => !$get('is_partner_student'))
->relationship('partner', 'name'),
]),
])->submitAction(new HtmlString(Blade::render('components.submit')))
]);
}
}
class RegistrationWizard extends Page implements HasForms
{
use InteractsWithForms;

protected static ?string $model = User::class;

protected static ?string $navigationIcon = 'heroicon-o-document-text';

protected static string $view = 'filament.pages.registration-wizard';

public $is_partner_student = false;

public function mount()
{
$this->form->fill();
}

public function form(Form $form): Form
{
return $form
->schema([
Wizard::make([
Wizard\Step::make('Degree Information')
->schema([
Radio::make('is_partner_student')
->label('Were you referred by one of our partners?')
->inline()
->boolean()
->live(),
Select::make('partner')
->hidden(fn (Get $get): bool => !$get('is_partner_student'))
->relationship('partner', 'name'),
]),
])->submitAction(new HtmlString(Blade::render('components.submit')))
]);
}
}
Bardolf#6969
Bardolf#69692w ago
@Ross Bearman isn't that what this line is doing?
protected static ?string $model = User::class;
protected static ?string $model = User::class;
Solution
Tetracyclic
Tetracyclic2w ago
The $model property is only (I think) used on Resources. If you're creating a custom page that interacts with a single record, you need a way to bind it to a specific record, so you need to set ->model() on the form itself