symfony/ux-autocomplete
JavaScript-powered autocomplete for Symfony forms. Enhances select and entity fields with search-as-you-type suggestions, async loading, and a smooth UX. Part of Symfony UX; docs and issues live in the main symfony/ux repository.
AutocompleteController), enabling modular adoption (e.g., drop-in for specific form fields without full bundle migration).AsEntityAutocompleteField trait) but supports remote data via custom endpoints. Aligns with Symfony’s ORM-first philosophy.EntityType, ChoiceType, or custom form fields via BaseEntityAutocompleteType. No need to rewrite existing form logic./autocomplete) but allows customization (e.g., route parameter in AsEntityAutocompleteField).symfony/asset-mapper) for CSS/JS, reducing manual asset pipeline work.| Risk Area | Severity | Mitigation |
|---|---|---|
| Symfony Version Lock | High | Requires Symfony 7.4+ (or downgrade to v2.x). Plan upgrade if on older versions. |
| PHP 8.4 Dependency | Medium | Test compatibility with PHP 8.3 if needed (check changelog for deprecations). |
| TomSelect.js Dependency | Low | Version pinned to 2.2.2+; minor updates unlikely to break integration. |
| XSS Vulnerabilities | Critical | Fixed in v2.36+ (HTML escaping enabled by default). Audit custom endpoints. |
| LiveComponent Compatibility | Medium | Test with Symfony 7.0+ LiveComponents (known issues in v2.14+). |
| Custom Endpoint Complexity | Medium | Requires manual route/controller setup for non-entity data. |
Symfony Ecosystem Readiness:
BaseEntityAutocompleteType with minimal changes?Data Source Compatibility:
max_results)?Performance:
max_results + pagination.)UI/UX Customization:
clear_button)?Migration Path:
ParentEntityAutocompleteType that need refactoring?Security:
csrf_token is recommended)?LIKE wildcards)?Monitoring:
EntityType, ChoiceType).QueryBuilder)./autocomplete endpoint).symfony/asset-mapper).clear_button, remove_button).| Phase | Tasks | Dependencies | Risk |
|---|---|---|---|
| Assessment | Audit existing form fields for autocomplete candidates. | None | Low |
| Dependency Setup | Add symfony/ux-autocomplete (v3.x) and symfony/asset-mapper to composer.json. |
Symfony 7.4+, PHP 8.4+ | Medium (version lock) |
| Basic Integration | Replace EntityType with BaseEntityAutocompleteType for 1–2 high-impact forms. |
Doctrine, Stimulus setup | Low |
| Customization | Configure TomSelect options (e.g., minCharacters, tom_select_options.plugins). |
Frontend team review | Medium (UI polish) |
| Advanced Features | Implement custom endpoints for non-entity data; add pagination (max_results). |
Backend route/controller setup | High (complex queries) |
| Testing | Validate: |
| Component | Compatibility Notes |
|---|---|
| Symfony Forms | Works with EntityType, ChoiceType, or custom types extending BaseEntityAutocompleteType. |
| Doctrine ORM | Optimized for entity search via QueryBuilder. Supports UUIDs, complex IDs. |
| Symfony UX | Requires Stimulus 1.0+. Integrates with Turbo/LiveComponents (tested in v2.14+). |
| Asset Pipeline | Uses symfony/asset-mapper (v5.3+) for CSS/JS. Manual Webpack Encore setup not required. |
| Custom Endpoints | Supports remote data via custom routes/controllers. Must return JSON with results and data fields. |
| LiveComponents | Tested in v2.14+; may require reset_on_focus option for dynamic forms. |
| Mercure | Not bundled, but can be integrated for real-time updates (e.g., live search results). |
EntityType fields in admin panels or CRUD interfaces (e.g., user search, product lookup).AsEntityAutocompleteField for minimal boilerplate.minCharacters: 2, plugins: { clear_button: false }).tom_select_options.css.max_results) and loading states.How can I help you explore Laravel packages today?