PHPackages                             openforce/select2-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. openforce/select2-bundle

ActiveSymfony-bundle

openforce/select2-bundle
========================

symfony select2 entity form type

v1.1.1(4y ago)0781MITPHPPHP &gt;=7.0.8

Since Aug 13Pushed 4y ago1 watchersCompare

[ Source](https://github.com/openforce-jp/select2-bundle)[ Packagist](https://packagist.org/packages/openforce/select2-bundle)[ RSS](/packages/openforce-select2-bundle/feed)WikiDiscussions main Synced today

READMEChangelog (3)Dependencies (3)Versions (4)Used By (0)

select2-bundle
==============

[](#select2-bundle)

Introduction
------------

[](#introduction)

This is a symfony Entity Form Type that supports select2 without using a controller. It's so easy and simple.

Installation
============

[](#installation)

Make sure Composer is installed globally, as explained in the [installation chapter](https://getcomposer.org/doc/00-intro.md)of the Composer documentation.

### Step 1: Download the Bundle

[](#step-1-download-the-bundle)

Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:

```
$ composer require openforce/select2-bundle
```

### Step 2: Enable the Bundle

[](#step-2-enable-the-bundle)

Then, enable the bundle by adding it to the list of registered bundles in the `config/bundles.php` file of your project:

```
// config/bundles.php

return [
    // ...
    \Openforce\Select2Bundle\OpenforceSelect2Bundle::class => ['all' => true],
];
```

### Step 3: Configure twig.yaml file

[](#step-3-configure-twigyaml-file)

```
twig:

    form_themes:
        - "@OpenforceSelect2/select2_type.html.twig"
```

### Step 4: Add select2 to your template

[](#step-4-add-select2-to-your-template)

```
//Add your template file

```

How to use
----------

[](#how-to-use)

The main options are:

- `class` Required. Your target entity.
- `search_field` Required. Entity field name you want to use for your search.
- `choice_label` Optional. Entity field name you want to display on the label. default value is `__toString`.
- `max_results` Optional. Number to display on page.
- `filter` Optional. It is callback function. If you use this, you don't need to define `search_field`.
- `related_fields` Optional. This option allows you to use the values you enter in other fields with the `filter` option.

```
// your Controller file
    public function index(){

        $formBuildr = $this->createFormBuilder();
        $formBuilder->add('price', InputType::class);
        $formBuilder->add("product", Select2Type::class,[
            'class' => Product::class,
            'search_field' => 'name',
            'choice_label' => 'name',
            'max_results' => 50,
            'related_fields' => ['price'],
            'filter' => function(EntityRepository $er, $value, $relatedFields){
                return $er->createQueryBuilder("p")
                    ->where("p.description like :word and p.price < :price")
                    ->setParameter("word", "%".$value."%")
                    ->setParameter('price', $relatedFields['price'])
                    ->orderBy("p.productId")
                    ;
            }
        ])
    }
```

###  Health Score

25

—

LowBetter than 40% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~1 days

Total

3

Last Release

1680d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/fc3e60e9bd9eac81f36e3bcef4e380e2c9449c3a9e340077c1dcf2aa49773e71?d=identicon)[openforce-jp](/maintainers/openforce-jp)

---

Top Contributors

[![openforce-jp](https://avatars.githubusercontent.com/u/2454289?v=4)](https://github.com/openforce-jp "openforce-jp (2 commits)")

### Embed Badge

![Health badge](/badges/openforce-select2-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/openforce-select2-bundle/health.svg)](https://phpackages.com/packages/openforce-select2-bundle)
```

###  Alternatives

[friendsofsymfony/ckeditor-bundle

Provides a CKEditor integration for your Symfony project.

52514.1M46](/packages/friendsofsymfony-ckeditor-bundle)[akeneo/pim-community-dev

Akeneo PIM, the future of catalog management is open!

1.0k610.8k78](/packages/akeneo-pim-community-dev)[mapbender/mapbender

Mapbender library

10117.0k5](/packages/mapbender-mapbender)[hackzilla/ticket-bundle

This Bundle provides multilingual ticketing functionality for Symfony applications.

6429.3k1](/packages/hackzilla-ticket-bundle)[nucleos/profile-bundle

Registration and profile management for symfony

12212.5k1](/packages/nucleos-profile-bundle)[leapt/core-bundle

Symfony LeaptCoreBundle

2528.6k3](/packages/leapt-core-bundle)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
