phloxcz/forms-dropdownlist

Searchable DropDownList form control for Nette Framework with AJAX-powered Selection datasource.

Maintainers

Package info

github.com/phloxcz/forms-dropdownlist

pkg:composer/phloxcz/forms-dropdownlist

Statistics

Installs: 2

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.1 2026-03-29 18:05 UTC

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.

📖 Full documentation →

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