mirror of
https://github.com/filamentphp/filament.git
synced 2026-09-24 15:42:09 +08:00
Update 04-pages.md
This commit is contained in:
@@ -54,23 +54,35 @@ protected function getHeaderActions(): array
|
||||
}
|
||||
```
|
||||
|
||||
### Default action
|
||||
### Opening an action modal when a page loads
|
||||
|
||||
You can also easily trigger an action to be launched when a page loads. Just add a method that returns your action and then set the `$defaultAction` property to the name of that action:
|
||||
You can also open an action when a page loads by setting the `$defaultAction` property to the name of the action you want to open:
|
||||
|
||||
```php
|
||||
use Filament\Actions\Action;
|
||||
|
||||
public $defaultAction = 'onboardingAction';
|
||||
public $defaultAction = 'onboarding';
|
||||
|
||||
public function onboardingAction(): Action
|
||||
{
|
||||
return Action::make('onboardingAction')
|
||||
return Action::make('onboarding')
|
||||
->modalHeading('Welcome')
|
||||
->visible(fn () => ! auth()->user()->isOnBoarded());
|
||||
->visible(fn (): bool => ! auth()->user()->isOnBoarded());
|
||||
}
|
||||
```
|
||||
|
||||
You can also pass an array of arguments to the default action using the `$defaultActionArguments` property:
|
||||
|
||||
```php
|
||||
public $defaultActionArguments = ['step' => 2];
|
||||
```
|
||||
|
||||
Alternatively, you can open an action modal when a page loads by specifying the `defaultAction` as a query string parameter to the page:
|
||||
|
||||
```
|
||||
/admin/products/edit/932510?defaultAction=onboarding
|
||||
```
|
||||
|
||||
### Refreshing form data
|
||||
|
||||
If you're using actions on an [Edit](resources/editing-records) or [View](resources/viewing-records) resource page, you can refresh data within the main form using the `refreshFormData()` method:
|
||||
|
||||
Reference in New Issue
Block a user