yepsua / filament-range-field
The missing range/slider field for the Filament forms.
Installs: 43 386
Dependents: 1
Suggesters: 0
Security: 0
Stars: 35
Watchers: 1
Forks: 13
Open Issues: 3
Requires
- php: ^8.0
- filament/filament: ^3.0
- illuminate/contracts: ^8.0|^9.0|^10.0
- spatie/laravel-package-tools: ^1.9.2
Requires (Dev)
- nunomaduro/collision: ^6.0
- nunomaduro/larastan: ^2.0.1
- orchestra/testbench: ^7.0
- pestphp/pest: ^1.21
- pestphp/pest-plugin-laravel: ^1.1
- phpstan/extension-installer: ^1.1
- phpstan/phpstan-deprecation-rules: ^1.0
- phpstan/phpstan-phpunit: ^1.0
- phpunit/phpunit: ^9.5
- spatie/laravel-ray: ^1.26
This package is auto-updated.
Last update: 2024-10-29 07:47:00 UTC
README
Installation
You can install the package via composer:
composer require yepsua/filament-range-field
Publish the assets:
php artisan filament:assets
You must see something like in the console:
php artisan filament:assets ... public/css/yepsua/filament-range-field/range-input-component.css ...
Optionally, you can publish the views using
php artisan vendor:publish --tag="filament-range-field-views"
Basic usage
By default the range is used to get value from 0 to 100.
use Yepsua\Filament\Forms\Components\RangeSlider ... protected function getFormSchema(): array { return [ ... RangeSlider::make('range') ... ]; } ...
Defining the steps:
use Yepsua\Filament\Forms\Components\RangeSlider ... protected function getFormSchema(): array { return [ ... RangeSlider::make('range')->steps([ 'A', // should get value: 1 for the A 'B', // should get value: 2 for the B 'C', // should get value: 3 for the C 'D' // should get value: 4 for the D ]) ... ]; } ...
Associative Array:
use Yepsua\Filament\Forms\Components\RangeSlider ... protected function getFormSchema(): array { return [ ... RangeSlider::make('range')->steps([ '25' => 'A', // should get value: 25 for the A '50' => 'B', // should get value: 50 for the B '75' => 'C', // should get value: 75 for the C '100' => 'D' // should get value: 100 for the D ]) ... ]; } ...
Hide the Step List:
use Yepsua\Filament\Forms\Components\RangeSlider ... protected function getFormSchema(): array { return [ ... RangeSlider::make('range')->steps([ 'A', 'B', 'C', 'D' ])->displaySteps(false) ... ]; } ...
📕 Note: The step value is defined by the first item in the steps array, Ex. => [25, 50, 75, 100] the step value should be 25. However if you need to define any other step value you can use the setter step.
RangeSlider::make('range')->steps([ 0 => '0', 25 => '25', 50 => '50', 75 => '75', 100 => '100' ])->step(25) ...
The same case applies for the min and max setters:
RangeSlider::make('range')->min(25)->max(75)->step(5)
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.