[增添]添加了datasource的setting数据库以及默认值
This commit is contained in:
56
vendor/filament/actions/docs/07-prebuilt-actions/03-view.md
vendored
Normal file
56
vendor/filament/actions/docs/07-prebuilt-actions/03-view.md
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
---
|
||||
title: View action
|
||||
---
|
||||
|
||||
## Overview
|
||||
|
||||
Filament includes a prebuilt action that is able to view Eloquent records. When the trigger button is clicked, a modal will open with information inside. Filament uses form fields to structure this information. All form fields are disabled, so they are not editable by the user. You may use it like so:
|
||||
|
||||
```php
|
||||
use Filament\Actions\ViewAction;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
|
||||
ViewAction::make()
|
||||
->record($this->post)
|
||||
->form([
|
||||
TextInput::make('title')
|
||||
->required()
|
||||
->maxLength(255),
|
||||
// ...
|
||||
])
|
||||
```
|
||||
|
||||
If you want to view table rows, you can use the `Filament\Tables\Actions\ViewAction` instead:
|
||||
|
||||
```php
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Tables\Actions\ViewAction;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
public function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->actions([
|
||||
ViewAction::make()
|
||||
->form([
|
||||
TextInput::make('title')
|
||||
->required()
|
||||
->maxLength(255),
|
||||
// ...
|
||||
]),
|
||||
]);
|
||||
}
|
||||
```
|
||||
|
||||
## Customizing data before filling the form
|
||||
|
||||
You may wish to modify the data from a record before it is filled into the form. To do this, you may use the `mutateRecordDataUsing()` method to modify the `$data` array, and return the modified version before it is filled into the form:
|
||||
|
||||
```php
|
||||
ViewAction::make()
|
||||
->mutateRecordDataUsing(function (array $data): array {
|
||||
$data['user_id'] = auth()->id();
|
||||
|
||||
return $data;
|
||||
})
|
||||
```
|
||||
Reference in New Issue
Block a user