martin-ro / filament-charcount-field
此包已被废弃,不再维护。未建议替代包。
具有字符计数的 Filament 字段。
0.1.5
2022-06-03 04:51 UTC
Requires
- php: ^8.0
- filament/filament: ^2.10
- illuminate/contracts: ^8.73|^9.0
Requires (Dev)
- nunomaduro/collision: ^5.10|^6.1
- orchestra/testbench: ^6.22|^7.0
- pestphp/pest: ^1.21
- pestphp/pest-plugin-laravel: ^1.1
- phpunit/phpunit: ^9.5
- spatie/laravel-ray: ^1.26
README
为 Filament 提供字符计数 TextInput & Textarea。
此包为 Filament Admin 和 Forms 提供具有字符计数显示的 TextInput 和 Textarea 组件。
TextInput
use MartinRo\FilamentCharcountField\Components\CharcountedTextInput; CharcountedTextInput::make('title') ->minCharacters(5) ->maxCharacters(10),
Textarea
use MartinRo\FilamentCharcountField\Components\CharcountedTextarea; CharcountedTextarea::make('title') ->minCharacters(5) ->maxCharacters(10),
演示
安装
首先,安装包
composer require martin-ro/filament-charcount-field
将组件添加到 Filament 资源表单中
<?php namespace App\Filament\Resources; // ... use MartinRo\FilamentCharcountField\Components\CharcountedTextInput; use MartinRo\FilamentCharcountField\Components\CharcountedTextarea; class PostResource extends Resource { // ... public static function form(Form $form): Form { return $form->schema([ // ... // TextInput CharcountedTextInput::make('title') ->label('Title') ->hintIcon('heroicon-o-code') ->hint('Title tag in header') ->helperText('While Google does not specify a length for title tags, usually the first 50–60 characters are displayed.') ->minCharacters(50) ->maxCharacters(60), // Textarea CharcountedTextarea::make('description') ->label('Description') ->rows(4) ->hintIcon('heroicon-o-code') ->hint('Meta description tag in header') ->helperText('Meta descriptions can technically be any length, but Google generally truncates snippets to ~155-160 characters.') ->minCharacters(155) ->maxCharacters(160), // .. ]); } // ... }


