{"id":28487805,"url":"https://github.com/defstudio/filament-searchable-input","last_synced_at":"2026-02-24T09:22:08.562Z","repository":{"id":284140696,"uuid":"953882520","full_name":"defstudio/filament-searchable-input","owner":"defstudio","description":"A searchable autocomplete input for Filament","archived":false,"fork":false,"pushed_at":"2026-02-09T08:47:12.000Z","size":395,"stargazers_count":32,"open_issues_count":3,"forks_count":7,"subscribers_count":3,"default_branch":"main","last_synced_at":"2026-02-23T13:31:47.316Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/defstudio.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":".github/SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":["fabio-ivona","defstudio"],"custom":["https://paypal.me/defstudiosrl"]}},"created_at":"2025-03-24T08:27:18.000Z","updated_at":"2026-02-09T08:47:11.000Z","dependencies_parsed_at":"2025-03-24T11:39:13.483Z","dependency_job_id":"d40b8190-9565-4514-b1da-29449d2918a9","html_url":"https://github.com/defstudio/filament-searchable-input","commit_stats":null,"previous_names":["defstudio/filament-searchable-input"],"tags_count":33,"template":false,"template_full_name":"filamentphp/plugin-skeleton","purl":"pkg:github/defstudio/filament-searchable-input","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/defstudio%2Ffilament-searchable-input","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/defstudio%2Ffilament-searchable-input/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/defstudio%2Ffilament-searchable-input/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/defstudio%2Ffilament-searchable-input/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/defstudio","download_url":"https://codeload.github.com/defstudio/filament-searchable-input/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/defstudio%2Ffilament-searchable-input/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29777832,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-24T04:54:30.205Z","status":"ssl_error","status_checked_at":"2026-02-24T04:53:58.628Z","response_time":75,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-06-08T05:07:59.716Z","updated_at":"2026-02-24T09:22:08.522Z","avatar_url":"https://github.com/defstudio.png","language":"PHP","funding_links":["https://github.com/sponsors/fabio-ivona","https://github.com/sponsors/defstudio","https://paypal.me/defstudiosrl"],"categories":[],"sub_categories":[],"readme":"# Filament Searchable Input\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/defstudio/filament-searchable-input.svg)](https://packagist.org/packages/defstudio/filament-searchable-input)\n[![GitHub Code Style Action Status](https://img.shields.io/github/actions/workflow/status/defstudio/filament-searchable-input/fix-php-code-style-issues.yml?branch=main\u0026label=code%20style)](https://github.com/defstudio/filament-searchable-input/actions/workflows/fix-php-code-style-issues.yml?query=workflow%3Afix-php-code-style-issues+branch%3Amain)\n[![Total Downloads](https://img.shields.io/packagist/dt/defstudio/filament-searchable-input.svg)](https://packagist.org/packages/defstudio/filament-searchable-input)\n\n\nA searchable autocomplete input for Filament\n\n![image](https://github.com/user-attachments/assets/6e85aa0e-13b5-4776-ae96-b3abc23d9f5f)\n\n[Demo](https://github.com/user-attachments/assets/cdc816c4-fa80-46f7-bb7b-43f2f018f61e)\n\n\n## Installation\n\nYou can install the package via composer:\n\n```bash\ncomposer require defstudio/filament-searchable-input\n```\n\nOptionally, you can publish the views using\n\n```bash\nphp artisan vendor:publish --tag=\"filament-searchable-input-views\"\n```\n\n\n## Usage\n\n`SearchableInput` is a component input built on top of TextInput, so any TextInput method is available, plus it allows to define a search function that will be executed whenever the user types something.\n\nHere's a basic implementation\n\n```php\nuse DefStudio\\SearchableInput\\Forms\\Components\\SearchableInput;\n\nclass ProductResource\n{\n    public static function form(Form $form): Form\n    {\n        return $form-\u003eschema([\n            SearchableInput::make('description')\n                -\u003eoptions([\n                    'Lorem ipsum dolor',\n                    'Aspernatur labore qui fugiat',\n                    'Dolores tempora libero assumenda',\n                    'Qui rem voluptas officiis ut non',\n                    \n                    //..\n                    \n                ])\n        ]);\n    }\n}\n```\n\n### Value-Label pairs options\n\nOptions can be defined also as an array of Value and Label pairs.\n\nThe `Value` will be inserted in the Input field when the user select an item. The `Label` is just used as a display value inside the search dropdown.\n\n\n```php\nuse DefStudio\\SearchableInput\\Forms\\Components\\SearchableInput;\n\nclass ProductResource\n{\n    public static function form(Form $form): Form\n    {\n        return $form-\u003eschema([\n            SearchableInput::make('description')\n                -\u003eoptions([\n                    'Lorem ipsum dolor' =\u003e '[A001] Lorem ipsum dolor.',\n                    'Aspernatur labore qui fugiat' =\u003e '[A001] Aspernatur labore qui fugiat.',\n                    'Dolores tempora libero assumenda' =\u003e '[A002] Dolores tempora libero assumenda.',\n                    'Qui rem voluptas officiis ut non' =\u003e '[A003] Qui rem voluptas officiis ut non.',\n                    \n                    //..\n                    \n                ])\n        ]);\n    }\n}\n```\n\n\n## Custom Search Function\n\nInstead (or along with) defining an `-\u003eoptions()` set, the search result set can be customized:\n\n```php\n\nuse DefStudio\\SearchableInput\\Forms\\Components\\SearchableInput;\n\nclass ProductResource\n{\n    public static function form(Form $form): Form\n    {\n        return $form-\u003eschema([\n            SearchableInput::make('description')\n                -\u003esearchUsing(function(string $search){\n                \n                    return Product::query()\n                        -\u003ewhere('description', 'like', \"%$search%\")\n                        -\u003eorWhere('code', 'like', \"%$search%\")\n                        -\u003elimit(15)\n                        -\u003epluck('description')\n                        -\u003evalues()\n                        -\u003etoArray();\n                        \n                    // Or, an associative array as well...\n                    \n                    return Product::query()\n                        -\u003ewhere('description', 'like', \"%$search%\")\n                        -\u003eorWhere('code', 'like', \"%$search%\")\n                        -\u003elimit(15)\n                        -\u003emapWithKeys(fn(Product $product) =\u003e [\n                            $product-\u003edescription =\u003e \"[$product-\u003ecode] $product-\u003edescription\"\n                        ])\n                        -\u003etoArray();            \n                        \n                        \n                    // Or, also, an array of complex items (see below)\n                })\n        ]);\n    }\n}\n```\n\n\n## Complex Items\n\n`SearchableInput` supports using arrays as search results, this allows to pass metadata to the selected item and consume it in the `-\u003eonItemSelected()` method:\n\n```php\n\nuse DefStudio\\SearchableInput\\Forms\\Components\\SearchableInput;\nuse DefStudio\\SearchableInput\\DTO\\SearchResult;\n\nclass ProductResource\n{\n    public static function form(Form $form): Form\n    {\n        return $form-\u003eschema([\n            SearchableInput::make('description')\n                -\u003esearchUsing(function(string $search){\n               \n                    return Product::query()\n                        -\u003ewhere('description', 'like', \"%$search%\")\n                        -\u003elimit(15)\n                        -\u003emap(fn(Product $product) =\u003e SearchResult::make($product-\u003edescription, \"[$product-\u003ecode] $product-\u003edescription\")\n                            -\u003ewithData('product_id', $product-\u003eid)\n                            -\u003ewithData('product_code', $product-\u003ecode) \n                        )\n                        -\u003etoArray()\n                        \n                })\n                -\u003eonItemSelected(function(SearchResult $item){\n                    $item-\u003evalue();\n                    $item-\u003elabel();\n                    $item-\u003eget('product_id');\n                    $item-\u003eget('product_code');\n                }),\n        ]);\n    }\n}\n```\n\n\n## Filament Utility Injection\n\nIn each of its methods, `SearchableInput` fully supports Filament utility injection in its methods, like:\n\n```php\n SearchableInput::make('description')\n    -\u003esearchUsing(function(string $search, array $options){ //options defined in -\u003eoptions([...]) \n        //...\n    })\n    -\u003esearchUsing(function(string $search, Get $get, Set $set){ //$get and $set utilities\n        //...\n    })\n    -\u003esearchUsing(function(string $search, $state){ //current field state\n        //...\n    })\n     -\u003esearchUsing(function(string $search, Component $component){ //current component instance\n        //...\n    })\n     -\u003esearchUsing(function(string $search, ?Model $record){ //current form record\n        //...\n    })\n     -\u003esearchUsing(function(string $search, string $operation){ //current form operation (create/update)\n        //...\n    });\n                \n\n```\n\n\n## Changelog\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.\n\n## Contributing\n\nPlease see [CONTRIBUTING](.github/CONTRIBUTING.md) for details.\n\n## Security Vulnerabilities\n\nPlease review [our security policy](../../security/policy) on how to report security vulnerabilities.\n\n## Credits\n\n- [Fabio Ivona](https://github.com/fabio-ivona)\n- [All Contributors](../../contributors)\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdefstudio%2Ffilament-searchable-input","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdefstudio%2Ffilament-searchable-input","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdefstudio%2Ffilament-searchable-input/lists"}