Add missing section for page hooks

This commit is contained in:
Abrar Ahmad
2024-11-14 11:53:15 +05:00
committed by GitHub
parent f930a75a70
commit c60a565375
@@ -102,6 +102,30 @@ protected function mutateFormDataBeforeFill(array $data): array
Alternatively, if you're viewing records in a modal action, check out the [Actions documentation](../../actions/prebuilt-actions/view#customizing-data-before-filling-the-form).
## Lifecycle hooks
Hooks may be used to execute code at various points within a page's lifecycle, like before a form is filled. To set up a hook, create a protected method on the View page class with the name of the hook:
There are several available hooks for the View pages:
```php
use Filament\Resources\Pages\ViewRecord;
class ViewUser extends ViewRecord
{
// ...
protected function beforeFill(): void
{
// Runs before the form fields are populated from the database.
}
protected function afterFill(): void
{
// Runs after the form fields are populated from the database.
}
}
```
## Authorization
For authorization, Filament will observe any [model policies](https://laravel.com/docs/authorization#creating-policies) that are registered in your app.