PHPackages                             liip/formtranslationchoice-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. [Validation &amp; Sanitization](/categories/validation)
4. /
5. liip/formtranslationchoice-bundle

AbandonedArchivedSymfony-bundle[Validation &amp; Sanitization](/categories/validation)

liip/formtranslationchoice-bundle
=================================

A Symfony2 bundle that provides a form choice and a validation constraint that work with translation domains.

1.0.0(12y ago)107621[2 issues](https://github.com/liip/LiipFormTranslationChoiceBundle/issues)MITPHPPHP &gt;=5.3.3

Since Sep 30Pushed 8y ago61 watchersCompare

[ Source](https://github.com/liip/LiipFormTranslationChoiceBundle)[ Packagist](https://packagist.org/packages/liip/formtranslationchoice-bundle)[ RSS](/packages/liip-formtranslationchoice-bundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (2)Used By (0)

FormTranslationChoiceBundle
===========================

[](#formtranslationchoicebundle)

UNMAINTAINED
============

[](#unmaintained)

This bundle is no longer maintained. Feel free to fork it if needed.

This Symfony2 bundle provides a form choice field type and a validation constraint that work with [translation domains](http://symfony.com/doc/current/book/translation.html#using-message-domains). You can use all strings of a translation domain as values for a field of your entity. The form stores the translation key in the field.

For example, we use it with an entity `Person` that has a field `title`. We use a translation domain `person_title` and maintain all possible titles a person can have (Mr, Ms, Prof, Dr, and so on) in the translation file. The entity stores the translation key and the title can thus be translated as needed. We could even change Mr to Mister without need to change the database.

This does not replace a choice field that links to another entity. But for simple cases like the above example, you might not want to build an admin interface and store such options in the database.

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

[](#installation)

```
php composer.phar require liip/formtranslationchoice-bundle --no-update
php composer.phar update liip/formtranslationchoice-bundle
```

Composer will ask you for the version of the bundle you want to install. Chose `1.0.*` unless you want to lock on a more specific version.

Enable the bundle
=================

[](#enable-the-bundle)

Load the bundle in your kernel:

```
// app/AppKernel.php
public function registerBundles()
{
  return array(
      // ...
      new Liip\FormTranslationChoiceBundle\LiipFormTranslationChoiceBundle(),
      // ...
  );
}
```

Due to the Symfony2 translator not exposing the translation domains, you need to use the extended translator provided by this bundle. Add the following to your project configuration file:

```
# app/config/config.yml
parameters:
    #...
    translator.class:      Liip\FormTranslationChoiceBundle\Translation\Translator
```

Usage
=====

[](#usage)

This bundle provides a form widget `translation_choice` and a validation constraint `TranslationDomainKey` that operate on a whole translation domain.

*Warning*: When using this, you want to make sure you have complete translation for the used domain, or none at all. This bundle does not merge different languages, but does fall back to the default language if the requested language does not exist.

translation\_choice Form Field Type
-----------------------------------

[](#translation_choice-form-field-type)

The `translation_choice` field type is based on the core `choice` and provides all translations of the specified domain as choices. You can use the options of the standard [Symfony2 choice field type](http://symfony.com/doc/current/reference/forms/types/choice.html). It makes no sense to specify the choice or choice\_list argument though, as they come from the translation domain.

To select the translation domain to use, the `translation_domain` option is required.

```
/** @var $builder FormBuilderInterface */
$builder
    ->add('title', 'translation_choice', array(
        'translation_domain' => 'person_title',
    ))
```

By default, the request locale is used, but you can set the `locale` option if you need to override this.

By default the values are sorted alphabetically. If you don't want them to be sorted use the `sorted' option set to false.

Validation constraint
---------------------

[](#validation-constraint)

This bundle provides a validation constraint that ensures that a field has a value that is a key in the specified translation domain. As with all validators, this validator accepts null and empty string as well, so you additionally want a NotBlank validation if empty values should not be allowed.

```
use Liip\FormTranslationChoiceBundle\Validator\Constraints as TranslationAssert;

// ...

/**
 * @TranslationAssert\TranslationDomainKey(translation_domain = "phone_type")
 */
private $type;
```

License
=======

[](#license)

This bundle is licensed under the MIT license. Please see the file LICENSE for more.

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance16

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

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

Unknown

Total

1

Last Release

4605d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/76576?v=4)[David Buchmann](/maintainers/dbu)[@dbu](https://github.com/dbu)

---

Top Contributors

[![dbu](https://avatars.githubusercontent.com/u/76576?v=4)](https://github.com/dbu "dbu (6 commits)")[![nonlux](https://avatars.githubusercontent.com/u/1284646?v=4)](https://github.com/nonlux "nonlux (2 commits)")[![lsmith77](https://avatars.githubusercontent.com/u/300279?v=4)](https://github.com/lsmith77 "lsmith77 (1 commits)")

---

Tags

bundleformphpsymfonysymfony2-bundletranslationvalidationi18ntranslationSymfony2form

### Embed Badge

![Health badge](/badges/liip-formtranslationchoice-bundle/health.svg)

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

###  Alternatives

[apy/jsfv-bundle

Symfony2 Javascript Form Validation Bundle with localisation support

92770.5k](/packages/apy-jsfv-bundle)[siriusphp/validation

Data validation library. Validate arrays, array objects, domain models etc using a simple API. Easily add your own validators on top of the already dozens built-in validation rules

181743.3k13](/packages/siriusphp-validation)[arondeparon/laravel-request-sanitizer

An easy to use request sanitizer that allows you to sanitize your form data before validating it.

112151.6k1](/packages/arondeparon-laravel-request-sanitizer)[progsmile/request-validator

Simple PHP Request Validator

33113.3k1](/packages/progsmile-request-validator)[stroker/form

ZF2 module for extending forms with live clientside validation

4157.1k](/packages/stroker-form)

PHPackages © 2026

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