PHPackages                             opwoco/form-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. opwoco/form-bundle

ActiveLibrary[Templating &amp; Views](/categories/templating)

opwoco/form-bundle
==================

Symfony 3 form types to extend built-in types. Ideal for Select2 AJAX implementations.

010PHP

Since Sep 23Pushed 9y ago5 watchersCompare

[ Source](https://github.com/opwoco/FormBundle)[ Packagist](https://packagist.org/packages/opwoco/form-bundle)[ RSS](/packages/opwoco-form-bundle/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependenciesVersions (1)Used By (0)

FormBundle
==========

[](#formbundle)

This bundle provide FormTypes extending ChoiceType, EntityType and DocumentType to let them accept additional choices added on the client side.

Ideal for [Select2](https://select2.github.io/) integration.

Works with Symfony ~2.8 || ~3.0

Features
========

[](#features)

The bundle provide 6 FormTypes designed to automate some common tasks :
-----------------------------------------------------------------------

[](#the-bundle-provide-6-formtypes-designed-to-automate-some-common-tasks-)

- ***AutocompleteType*** : Extension for the built-in TextType

    - **Configuration** : Insert %alsatian\_form.parameters.autocomplete.attr\_class% as class for the HTML input.
    - **Options** : 'route' and 'route\_params' to render a data-ajax--url tag in the HTML input.
- ***DatepickerType*** : Extension for the built-in DateType

    - **Automatic** : Sets the date pattern with \\IntlDateFormatter::SHORT and renders it as 'pattern' attribute in the HTML input.
    - **Configuration** : Insert %alsatian\_form.parameters.date\_picker.attr\_class% as class for the HTML input.
- ***DateTimepickerType*** : Extension for the built-in DateTimeType

    - **Automatic** : Sets the date pattern with \\IntlDateFormatter::SHORT and renders it as 'pattern' attribute in the HTML input.
    - **Configuration** : Insert %alsatian\_form.parameters.datetime\_picker.attr\_class% as class for the HTML input.
- ***ExtensibleChoiceType*** : Extension for the built-in ChoiceType

    - **Automatic** : Starts with an empty HTML select and accept each submitted choice which has be added on the client side.
    - **Configuration** : Insert %alsatian\_form.parameters.extensible\_choice.attr\_class% as class for the HTML select.
    - **Options** : 'route' and 'route\_params' to render a data-ajax--url tag in the HTML select.
- ***ExtensibleDocumentType*** : Extension for the built-in DocumentType

    - **Automatic** : Starts with an empty HTML select and accept each valid document which has be added on the client side.
    - **Configuration** : Insert %alsatian\_form.parameters.extensible\_document.attr\_class% as class for the HTML select.
    - **Options** : 'route' and 'route\_params' to render a data-ajax--url tag in the HTML select.
- ***ExtensibleEntityType*** : Extension for the built-in EntityType

    - **Automatic** : Starts with an empty HTML select and accept each valid entity which has be added on the client side.
    - **Configuration** : Insert %alsatian\_form.parameters.extensible\_entity.attr\_class% as class for the HTML select.
    - **Options** : 'route' and 'route\_params' to render a data-ajax--url tag in the HTML select.

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

[](#installation)

***Download the bundle with composer***

```
    composer require alsatian/form-bundle
```

***Enable the bundle***

Add the bundle to app/AppKernel.php :

```
// app/AppKernel.php

class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            // ...

            new Alsatian\FormBundle\AlsatianFormBundle(),
        );

        // ...
    }

    // ...
}
```

Configuration
=============

[](#configuration)

Add following lines to app/config/config.yml

```
alsatian_form:
    extensible_choice: ~   # To enable Alsatian\FormBundle\Form\ExtensibleChoiceType
    extensible_entity: ~   # To enable Alsatian\FormBundle\Form\ExtensibleEntityType
    extensible_document: ~ # To enable Alsatian\FormBundle\Form\ExtensibleDocumentType

```

For each FormType you can configure a default attr\_class parameter, like this :

```
alsatian_form:
    extensible_choice:
        attr_class: select2 # Adds class="select2" in the HTML select element
    extensible_entity:
        attr_class: select2-entity # Adds class="select2-entity" in the HTML select element
    extensible_document:
        attr_class: select2-document # Adds class="select2-document" in the HTML select element

```

Usage
=====

[](#usage)

To use these FormTypes :

```
    use Alsatian\FormBundle\Form\ExtensibleChoiceType;
    use Alsatian\FormBundle\Form\ExtensibleEntityType;
    use Alsatian\FormBundle\Form\ExtensibleDocumentType;

    // Without route
    $builder->add('extensible_choice', ExtensibleChoiceType::class);
    $builder->add('extensible_entity', ExtensibleEntityType::class,array('class'=>'AppBundle:Article','choice_label'=>'name'));
    $builder->add('extensible_document', ExtensibleDocumentType::class,array('class'=>'AppBundle:Article','choice_label'=>'name'));

    // With route (generate the route defined as 'route' option and renders it as 'data-ajax-url' html attribute)
    $builder->add('extensible_choice', ExtensibleChoiceType::class,array('route'=>'ajax_choices'));
    $builder->add('extensible_entity', ExtensibleEntityType::class,array('route'=>'ajax_entities','class'=>'AppBundle:Article','choice_label'=>'name'));
    $builder->add('extensible_document', ExtensibleDocumentType::class,array('route'=>'ajax_documents','class'=>'AppBundle:Article','choice_label'=>'name'));
```

This will render HTML like :

```

```

The aim of this bundle is only to do the server side work (allowing "extensible" choices). You have to write your own Javescript adapters to get it work with Select2.

As example, how I use it :

```
$(document).ready(function(){
	$('.select2').each(function(){
		var configs={
		        allowClear: true,
		        width:'resolve',
			ajax:{
				data: function (params) {return {q: params.term};},
				dataType:'json',delay: 250,
				processResults: function (data) {
					var dataresults = [];
					$.each(data, function(key, val){
						dataresults.push({id: val[0], text: val[1]});
					});
					return { results: dataresults };
				}
			};
		};

		$(this).select2(configs);
	});
});
```

###  Health Score

20

—

LowBetter than 13% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 98.2% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/e2cf74c4011208fdf63cb17a29c22f9b4f587c5654459835e1bc38472e91d7fc?d=identicon)[opwoco](/maintainers/opwoco)

---

Top Contributors

[![Alsatian67](https://avatars.githubusercontent.com/u/7631072?v=4)](https://github.com/Alsatian67 "Alsatian67 (107 commits)")[![pascalwacker](https://avatars.githubusercontent.com/u/772008?v=4)](https://github.com/pascalwacker "pascalwacker (2 commits)")

### Embed Badge

![Health badge](/badges/opwoco-form-bundle/health.svg)

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

###  Alternatives

[limenius/react-bundle

Client and Server-side react rendering in a Symfony Bundle

3861.2M](/packages/limenius-react-bundle)[area17/laravel-auto-head-tags

Laravel Auto Head Tags helps you build the list of head elements for your app

4616.0k](/packages/area17-laravel-auto-head-tags)[jelix/wikirenderer

WikiRenderer is a library to generate HTML or anything else from wiki content.

1712.2k1](/packages/jelix-wikirenderer)[webkinder/sproutset

A Composer package for handling responsive images in Roots Bedrock + Sage + Blade projects.

281.8k](/packages/webkinder-sproutset)

PHPackages © 2026

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