Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Select2Entity Bundle

Select2Entity Bundle Laravel Package

tetranz/select2entity-bundle

Symfony bundle integrating Select2 with Doctrine entities: AJAX search, dynamic loading, and autocompletion for entity fields in forms. Supports remote endpoints, custom queries, pagination, and transforming selections to entities for smooth UX.

View on GitHub
Deep Wiki
Context7

A Symfony2 bundle that integrates Select2 as a drop-in replacement for a standard entity field on a Symfony form.

Frequently asked questions about Select2Entity Bundle
Can I use this bundle directly in Laravel since it’s a Symfony package?
No, this bundle is designed for Symfony and won’t work out-of-the-box in Laravel due to framework differences. Laravel lacks Symfony’s form system and Twig templating, so you’d need to manually integrate Select2 via JavaScript or use a Laravel-compatible alternative like `spatie/laravel-select`.
How do I implement Select2 for entity selection in Laravel without Symfony?
For Laravel, use the standalone Select2 library (via npm) with Laravel Mix/Webpack for assets. Fetch entities via AJAX using Laravel’s API routes, then bind the results to Select2. Alternatively, consider packages like `laravel-select2` or `vinkla/select2-symfony` (if you’re open to Symfony).
Does this bundle support Laravel’s Blade templating instead of Twig?
No, the bundle relies on Twig templates for rendering forms. In Laravel, you’d need to manually recreate the Select2 UI in Blade or use JavaScript to dynamically render the dropdown without templating dependencies. This adds complexity but is feasible for simple implementations.
What Laravel versions does this bundle officially support?
This bundle is Symfony-focused and has no official Laravel support. However, the underlying Select2 library works with any modern Laravel version (5.8+) if integrated via JavaScript. For form integration, you’d need to adapt Symfony’s `EntityType` logic to Laravel’s `Form` or `Collective` packages.
How do I handle AJAX entity fetching in Laravel for Select2?
Create API routes in Laravel to return filtered entity data (e.g., `/api/entities?search=term`). Use Laravel’s `Resource` classes or JSON responses to format data for Select2. Cache responses to improve performance, especially for large datasets.
Are there alternatives to this bundle that work natively in Laravel?
Yes, consider `laravel-select2` (GitHub) or `vinkla/select2-symfony` (if you’re open to Symfony). For a lightweight approach, use the standalone Select2 npm package with Laravel Mix and custom AJAX endpoints. Packages like `spatie/laravel-select` also offer similar functionality.
Will this bundle work with Laravel’s Form Request validation?
No, the bundle is tied to Symfony’s validation system. In Laravel, you’d need to manually validate Select2-submitted data via Form Requests or API middleware. The bundle’s form type helpers won’t integrate with Laravel’s validation pipeline.
How do I customize the Select2 query builder for Doctrine entities?
In Symfony, the bundle provides query builder customization via configuration. For Laravel, you’d need to manually define the query logic in your API controller or service. Use Eloquent’s query builder to filter entities based on search terms, then return JSON for Select2.
Is this bundle actively maintained? Should I use it for a new project?
The last release was in 2020, indicating low maintenance activity. For new projects, evaluate alternatives like `laravel-select2` or standalone Select2 with Laravel. If you’re already using Symfony, this bundle is a solid choice, but Laravel users should opt for modern, actively maintained solutions.
Can I use this bundle in a microservices architecture with a Laravel backend?
Yes, but you’ll need to expose entity data via Laravel’s API (REST/GraphQL) and let the frontend (Symfony or Laravel) consume it. The bundle itself won’t integrate directly, but you can reuse its Symfony frontend logic if your frontend is Symfony-based. For Laravel-only microservices, use Select2 with custom API endpoints.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
capell-app/block-library
capell-app/frontend
capell-app/admin
capell-app/core
axium/identity
cetria/laravel-dummy-models
cetria/reflection-helper
agropredict/sso-auth-bundle
evolvestudio/spam-protection
directorytree/privacy-filter-classifier
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php