[增添]添加了datasource的setting数据库以及默认值

This commit is contained in:
makotocc0107
2024-08-27 09:57:44 +08:00
parent d111dfaea4
commit 72eb990970
10955 changed files with 978898 additions and 0 deletions

View 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;
})
```