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. [Templating &amp; Views](/categories/templating)
4. /
5. openforce/select2-bundle

ActiveSymfony-bundle[Templating &amp; Views](/categories/templating)

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 1mo ago

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 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity48

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

1729d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/2454289?v=4)[openforce-jp](/maintainers/openforce-jp)[@openforce-jp](https://github.com/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

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M648](/packages/sylius-sylius)[easycorp/easyadmin-bundle

Admin generator for Symfony applications

4.3k16.7M309](/packages/easycorp-easyadmin-bundle)[friendsofsymfony/ckeditor-bundle

Provides a CKEditor integration for your Symfony project.

53014.3M49](/packages/friendsofsymfony-ckeditor-bundle)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.0k15.4k](/packages/prestashop-prestashop)[contao/core-bundle

Contao Open Source CMS

1231.6M2.3k](/packages/contao-core-bundle)[ec-cube/ec-cube

EC-CUBE EC open platform.

78527.0k1](/packages/ec-cube-ec-cube)

PHPackages © 2026

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