diff --git a/packages/panels/docs/03-resources/05-viewing-records.md b/packages/panels/docs/03-resources/05-viewing-records.md index a98f93f57b..e1526bf9be 100644 --- a/packages/panels/docs/03-resources/05-viewing-records.md +++ b/packages/panels/docs/03-resources/05-viewing-records.md @@ -102,6 +102,29 @@ 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: + +```php +use Filament\Resources\Pages\ViewRecord; + +class ViewUser extends ViewRecord +{ + // ... + + protected function beforeFill(): void + { + // Runs before the disabled form fields are populated from the database. Not run on pages using an infolist. + } + + protected function afterFill(): void + { + // Runs after the disabled form fields are populated from the database. Not run on pages using an infolist. + } +} +``` + ## Authorization For authorization, Filament will observe any [model policies](https://laravel.com/docs/authorization#creating-policies) that are registered in your app.