[增添]添加了datasource的setting数据库以及默认值
This commit is contained in:
81
vendor/filament/forms/docs/03-fields/15-textarea.md
vendored
Normal file
81
vendor/filament/forms/docs/03-fields/15-textarea.md
vendored
Normal file
@@ -0,0 +1,81 @@
|
||||
---
|
||||
title: Textarea
|
||||
---
|
||||
import AutoScreenshot from "@components/AutoScreenshot.astro"
|
||||
|
||||
## Overview
|
||||
|
||||
The textarea allows you to interact with a multi-line string:
|
||||
|
||||
```php
|
||||
use Filament\Forms\Components\Textarea;
|
||||
|
||||
Textarea::make('description')
|
||||
```
|
||||
|
||||
<AutoScreenshot name="forms/fields/textarea/simple" alt="Textarea" version="3.x" />
|
||||
|
||||
## Resizing the textarea
|
||||
|
||||
You may change the size of the textarea by defining the `rows()` and `cols()` methods:
|
||||
|
||||
```php
|
||||
use Filament\Forms\Components\Textarea;
|
||||
|
||||
Textarea::make('description')
|
||||
->rows(10)
|
||||
->cols(20)
|
||||
```
|
||||
|
||||
### Autosizing the textarea
|
||||
|
||||
You may allow the textarea to automatically resize to fit its content by setting the `autosize()` method:
|
||||
|
||||
```php
|
||||
use Filament\Forms\Components\Textarea;
|
||||
|
||||
Textarea::make('description')
|
||||
->autosize()
|
||||
```
|
||||
|
||||
## Making the field read-only
|
||||
|
||||
Not to be confused with [disabling the field](getting-started#disabling-a-field), you may make the field "read-only" using the `readOnly()` method:
|
||||
|
||||
```php
|
||||
use Filament\Forms\Components\Textarea;
|
||||
|
||||
Textarea::make('description')
|
||||
->readOnly()
|
||||
```
|
||||
|
||||
There are a few differences, compared to [`disabled()`](getting-started#disabling-a-field):
|
||||
|
||||
- When using `readOnly()`, the field will still be sent to the server when the form is submitted. It can be mutated with the browser console, or via JavaScript. You can use [`dehydrated(false)`](advanced#preventing-a-field-from-being-dehydrated) to prevent this.
|
||||
- There are no styling changes, such as less opacity, when using `readOnly()`.
|
||||
- The field is still focusable when using `readOnly()`.
|
||||
|
||||
## Textarea validation
|
||||
|
||||
As well as all rules listed on the [validation](../validation) page, there are additional rules that are specific to textareas.
|
||||
|
||||
### Length validation
|
||||
|
||||
You may limit the length of the textarea by setting the `minLength()` and `maxLength()` methods. These methods add both frontend and backend validation:
|
||||
|
||||
```php
|
||||
use Filament\Forms\Components\Textarea;
|
||||
|
||||
Textarea::make('description')
|
||||
->minLength(2)
|
||||
->maxLength(1024)
|
||||
```
|
||||
|
||||
You can also specify the exact length of the textarea by setting the `length()`. This method adds both frontend and backend validation:
|
||||
|
||||
```php
|
||||
use Filament\Forms\Components\Textarea;
|
||||
|
||||
Textarea::make('question')
|
||||
->length(100)
|
||||
```
|
||||
Reference in New Issue
Block a user