CreateAction in Custom Page doesn't show form

Hello everyone! My goal is to create a page where the user can create some notes and see them saved as post-it notes on a wall. I have created a Custom Page, called Notes Wall, which is linked to the NotesResource. In the resource I have the various standard elements (model, navigationIcon, form() and so on. In the getPages function I have entered the url of the custom page in the ‘index’ key. In NotesWall.php, I have inserted the getHeaderActions function that returns the CreateAction but it does not return the NotesResource form. What am I missing? This is the code in NotesWall.php:
class NotesWall extends Page implements HasForms
{
use InteractsWithForms;

protected static string $resource = NoteResource::class;

protected static string $view = 'filament.resources.note-resource.pages.notes-wall';

protected function getHeaderActions(): array
{
return [
CreateAction::make()
->model(NoteResource::getModel()),
];
}
}
class NotesWall extends Page implements HasForms
{
use InteractsWithForms;

protected static string $resource = NoteResource::class;

protected static string $view = 'filament.resources.note-resource.pages.notes-wall';

protected function getHeaderActions(): array
{
return [
CreateAction::make()
->model(NoteResource::getModel()),
];
}
}
No description
Solution:
Hello, I think you should provide the form with ->form(). Here the model is just a way to tell where Filament should save the data according to the model.
Jump to solution
3 Replies
Solution
arnaudsf
arnaudsf5d ago
Hello, I think you should provide the form with ->form(). Here the model is just a way to tell where Filament should save the data according to the model.
toeknee
toeknee5d ago
You need to add the form field sin the noteresource
Davide Cariola
Davide CariolaOP5d ago
Hi guys, thank you so much! I've tried to use the form() function before but not in the right way. For future reference to others, this is the solution:
protected function getHeaderActions(): array
{
return [
CreateAction::make()
->model(NoteResource::getModel())
->form(fn(Form $form) => NoteResource::form($form)),
];
}
protected function getHeaderActions(): array
{
return [
CreateAction::make()
->model(NoteResource::getModel())
->form(fn(Form $form) => NoteResource::form($form)),
];
}

Did you find this page helpful?