phloxcz / forms-dropdownlist
Searchable DropDownList form control for Nette Framework with AJAX-powered Selection datasource.
v1.0.1
2026-03-29 18:05 UTC
Requires
- php: >=8.1
- nette/application: ^3.1
- nette/database: ^3.1
- nette/di: ^3.1
- nette/forms: ^3.1
- nette/utils: ^4.0
This package is auto-updated.
Last update: 2026-04-29 18:16:19 UTC
README
Searchable DropDownList form control for Nette Framework with AJAX-powered Nette\Database\Table\Selection datasource.
Installation
composer require phloxcz/forms-dropdownlist
Include the assets in your base layout:
<link rel="stylesheet" href="{$basePath}/vendor/phloxcz/forms-dropdownlist/assets/dropdownlist.css"> <script src="{$basePath}/vendor/phloxcz/forms-dropdownlist/assets/dropdownlist.js" defer></script>
Quick start
1. Register the DI extension
# config/common.neon extensions: dropdownlist: Phlox\Forms\DropDownList\DropDownListExtension
2. Add the control to your form
$form->addDropDownList('cityId', 'City', $this->link('searchCity!')) ->setSelection($this->database->table('cities'), 'id', 'name') ->setPlaceholder('Select city…') ->setTheme(DropDownListInput::THEME_BOOTSTRAP);
3. Handle the AJAX signal
public function handleSearchCity(string $q = ''): void { $this->sendJson($this['cityForm']['cityId']->fetchData($q)); }
4. Pre-fill on edit pages
$form->setValues(['cityId' => $entity->cityId]); // Label is resolved server-side – no extra AJAX on page load.
Themes
| Constant | Framework |
|---|---|
DropDownListInput::THEME_DEFAULT |
Framework-agnostic, uses CSS system colors |
DropDownListInput::THEME_BOOTSTRAP |
Bootstrap 5 |
DropDownListInput::THEME_TAILWIND |
Tailwind CSS 3 |
array $classes |
Custom class map |
License
MIT © Phlox