Code Monkey home page Code Monkey logo

filament-picker's Introduction

A Regular Picker for Filament Form

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

A Regular Picker for Filament Form.

image

image

Installation

You can install the package via composer:

composer require icetalker/filament-picker

Optionally, you can publish the views using

php artisan vendor:publish --tag="filament-picker-view"

Usage

public function form(Form $form): Form
{
    return $form
        ->schema([

            Picker::make('transport')
                ->label('Transport')
                ->options([
                    'ship' => 'By Sea',
                    'airplane' => 'By Air',
                    'truck' => 'By Truck',
                ])
                ->icons([
                    'ship' => 'heroicon-o-home',
                    'airplane' => 'heroicon-o-paper-airplane',
                    'truck' => 'heroicon-o-truck',
                ])
                ->imageSize(100)
                ->images([
                    'ship' => 'https://source.unsplash.com/random/100x100/?ship',
                    'airplane' => 'https://source.unsplash.com/random/100x100/?airplane',
                    'truck' => 'https://source.unsplash.com/random/100x100?truck',
                ])
                ->default('ship'),
        ]);
}

Define Options

To define options, you can use the options() method and pass an array of key-value pairs. The key will be the value of the option, and the value will be the label to be displayed.

Picker::make('transport')
    ->options([
        'ship' => 'By Sea',
        'airplane' => 'By Air',
        'truck' => 'By Truck',
    ]);

Add Icons

To add icons, you can use the icons() method and pass an array of key-value pairs. The key will be the value of the option, and the value will be the icon to be displayed:

Picker::make('transport')
    ->label('Transport')
    ->options([
        'ship' => 'By Sea',
        'airplane' => 'By Air',
        'truck' => 'By Truck',
    ])
    ->icons([
        'ship' => 'heroicon-o-home',
        'airplane' => 'heroicon-o-paper-airplane',
        'truck' => 'heroicon-o-truck',
    ])

Add Images

To add images, you can use the images() method and pass an array of key-value pairs. The key will be the value of the option, and the value will be the image url to be displayed:

Picker::make('transport')
    ->label('Transport')
    ->options([
        'ship' => 'By Sea',
        'airplane' => 'By Air',
        'truck' => 'By Truck',
    ])
    ->images([
        'ship' => 'https://source.unsplash.com/random/100x100/?ship',
        'airplane' => 'https://source.unsplash.com/random/100x100/?airplane',
        'truck' => 'https://source.unsplash.com/random/100x100?truck',
    ]);

The size of images is 50x50 by default, you can custom the size of images by using the imageSize() method and pass the size in pixels.

Default Value

To set a default value, you can use the default() method and pass the value of the option:

Picker::make('transport')
    ->label('Transport')
    ->options([
        'ship' => 'By Sea',
        'airplane' => 'By Air',
        'truck' => 'By Truck',
    ])
    ->default('ship');

Todo

  • Add Relationship Support
  • Add Validation

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.

filament-picker's People

Contributors

tubring avatar

Stargazers

Diogo Pereira avatar zzzzzz avatar Kairov Darkhan avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.