custom page form from resource

hi just want abit of advice i've added the element to my custom page:
<form wire:submit.prevent="submit">
{{ $this->form }}
</form>
<form wire:submit.prevent="submit">
{{ $this->form }}
</form>
and my custom page implements hasforms and use interactWithForms instead of creating a whole chunk of code in the Page like, which render fine ... :
public function form(Form $form): Form
{
return $form
->schema([
TextInput::make('title')
->required(),
// ...
])
->statePath('data');
}
public function form(Form $form): Form
{
return $form
->schema([
TextInput::make('title')
->required(),
// ...
])
->statePath('data');
}
can i pull the form from my resource?
6 Replies
LeandroFerreira
try return YourResource::form($form);
Mocus
MocusOP5d ago
thanks, this did work:
public function form(Form $form): Form
{
return PerformanceResource::form($form);
}
public function form(Form $form): Form
{
return PerformanceResource::form($form);
}
im already pulling protected static string $resource = PerformanceResource::class; in the page class, is there away to use this?
LeandroFerreira
what didn't work?
Mocus
MocusOP5d ago
huh? what you suggested did work by returning YourResource::form($form); in the public function form(Form $form) i was just curious if i could use the defined resouce already in my page rather then pulling it again :)
LeandroFerreira
ahh ok, try return static::$resource::form($form);
Mocus
MocusOP5d ago
ah yeah of course! perfect, thanks! i am wondering why it just doesnt pick it up form $resource since this is pointing to it 🧐 keeping the code abit cleaner

Did you find this page helpful?