How do I add Actions to the top of a form next to delete.
I would like to set up my forms so that the save buttons are at the top and bottom of the form, along with the delete, cancel, and view on front end.
You have the save buttons on the create form, but I do not know how to get them on the edit, nor how to add to the header.
the view on front end may not be on all models, so how would I add it manually to models that need it?
I created the actions below, but they dont do what they are supposed to do. So if there is prebuilt actions for this purpose, how do I add it either within the form or in the header/footers
Section::make()
->schema([
Actions::make([
Action::make('saveAndCreateAnother')
->label('Save & Create Another')
->button()
,
Action::make('saveAndClose')
->label('Save & Close')
->button(),
Action::make('cancel')
->label('Cancel')
->button(),
Action::make('viewFrontend')
->label('View on site')
->icon('heroicon-o-eye')
->button()
->url(fn($get
) => route('hobby',
$get('slug')))
->openUrlInNewTab(),
]),
10 Replies
this is done via the XResource/Pages/ListResource.php
just add header actions and footer actions with any built-iin or custoom actions you want
but still not sure about page footer actions
For the footer you may use a custom view with the same actions
The classes in the Pages directory are used to customize the pages in the app that interact with your resource.
You can use this to override the actions:
CreateXX.php
EditXX.php
To reduce code repetition, you could create a Trait for both pages and include the respective code from the Create and Edit examples.
thank you. but i need the view to go to the front end route based on the slug of the model.
I tried adding
And knowing what I can use in different parts is getting to be confusing.
If i wanted to put these actions within the form itself? where do they go?
I tried adding
Action::make('viewFrontend')
->label('View on site')
->icon('heroicon-o-eye')
->button()
->url(fn($get
) => route('hobby',
$get('slug')))
->openUrlInNewTab(),
instead of Actions\viewAction
I also tried
Actions\ViewAction::make()->url(fn($get
) => route('hobby',
$get('slug')))
->openUrlInNewTab(),
I am a bit confused with how filament works (and probably aspects of php in general
some things are classes some actions are functions,And knowing what I can use in different parts is getting to be confusing.
If i wanted to put these actions within the form itself? where do they go?
Action::make('cancel')
->getCancelFormAction()
->label('Cancel')
->button(),
doesn't work and neither do the other functions.Inject $record and use $record->slug instead of $get
I get "Object of type Modules\Hobbies\Models\Hobby is not callable "
i made it work with
->url(fn($record) => route('hobby', $record->slug))
i had
->url(fn($record
) => route('hobby',
$record('slug')))
before
one day ill figure this out
solved?
yes, i believe so. is there a way to change color beyond primary secondary, ect. I have my own colors in a css file, how do I utilize these?
Seems every filament loads another instance of tailwind css, so I am not sure how to prevent this, nor utilize custom css variables. I also have a textbox next to a checkbox. how can i align to the text area instead of the header?
Seems every filament loads another instance of tailwind css, so I am not sure how to prevent this, nor utilize custom css variables. I also have a textbox next to a checkbox. how can i align to the text area instead of the header?
Please open new topics if you have new questions. Check this section
alright