PHPackages                             bic/form-validation - 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. bic/form-validation

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

bic/form-validation
===================

Let's take the form validation logic and apply it for js, other php scripts, an API...

1.3.3(11y ago)41.1k[1 issues](https://github.com/bichotll/FormValidationBundle/issues)MITPHPPHP &gt;=5.3.3

Since Jun 27Pushed 11y ago1 watchersCompare

[ Source](https://github.com/bichotll/FormValidationBundle)[ Packagist](https://packagist.org/packages/bic/form-validation)[ Docs](https://github.com/bichotll/FormValidationBundle)[ RSS](/packages/bic-form-validation/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependencies (4)Versions (9)Used By (0)

FormValidationBundle
====================

[](#formvalidationbundle)

The objective of this bundle is to create a abstract and generic object of the form information to parse it to another tools (Javascript or maybe PHP tools).

For instance: It can help you to addapt this information to javascript validation logic for the forms.

\##Dependencies

Check composer.json of the current version.

\##Instalation

\####Composer

```
composer require bic/form-validation
```

\####Enable the bundle

```
//...
new Bic\FormValidationBundle\BicFormValidationBundle()
//...
```

\##How it works

\####Create the form

```
        // form Data models
        $formData = array(
            new Form\Model\Register(),
            new Form\Model\Document()
        );

        // form builder
        $formBuilder = $this->container
                ->get('form.factory')
                ->createNamedBuilder('form', 'form', $formData)
                ->add('phone', 'text')
                ->add('password', 'password')
                ->add('document', new Form\Type\DocumentType())
                ->add('submit', 'submit');

        // get form from form builder
        // (http://www.interesarte.com/wp-content/uploads/2013/05/willsmith.jpg)
        $form = $formBuilder
                ->getForm()
                ->handleRequest($request);
```

\####Extract the validation

```
        $formValidation = $this->get('bic_form_validation.form_validation');
        //returns FormValidation object
        $formValidation->extractValidation($form);
        //returns fields array
        $formValidation->getFields();
        //returns json object
        $formJson = $formValidation->toJson();
```

\####Return it to the view

```
        return array(
            //...
            'form_validation' => $formJson,
            //...
        );
```

And do whatever you want with it.

\##json form example

```
[
    {
        constraints: [
            "Default": [
                {
                    "message": "This value should not be null.",
                    "groups": [
                        "Default",
                        "Model"
                    ],
                    "class": "Symfony\\Component\\Validator\\Constraints\\NotNull"
                }
            ]
        ],
        dataClass: "Bic\Voucher\EntityBundle\Entity\Category",
        options: {
            choices: {
                m: "Male",
                f: "Female"
            },
            required: false,
            empty_value: "Choose your gender",
            empty_data: null
        },
        value: '',
        pathName: [
            "name",
            "bic_voucher_entitybundle_category"
        ],
        fullPathName: "bic_voucher_entitybundle_category[name]",
        type: "choice",
        validationGroups: [ ]
    },
    {
    constraints: [ ],
        dataClass: "Bic\Voucher\EntityBundle\Entity\Category",
        options: {
            required: false
        },
        value: '',
        pathName: [
            "miniDescription",
            "bic_voucher_entitybundle_category"
        ],
        fullPathName: "bic_voucher_entitybundle_category[miniDescription]",
        type: "textarea",
        validationGroups: [ ]
    }
]
```

[Full example](Resources/doc/fullExample.md)

\##Last changes

- Added entity results from the FormView object (dataEntityChoice property)
- Added JMS Serializer as dependency to get the entity type value and parse it to json
- Added value property. It has the value of the field.
- Removed the possibility to get the class name from the data passed
- Provide better and complete json example (from TODO)
- Create associated js parsers like ParsleyJs and js form generator script. (Out of project) (from TODO)
- FIXED - Does not work with complex forms. (from Known errors)
- More unit testing (from TODO)
- General info of form added
- Created first unit testing to check the bundle is working with complex forms
- Fix known errors (from TODO)
- Parent forms not avoided
- Submit buttons not avoided
- Added more form information
- Removed jQValidation generator
- Removed generator folder and strategy. Now the parsers will be aplied externally.

\##Related resources

\###[Js form creator](https://github.com/bichotll/Symfony-FormValidationBundle-js-parser)It creates the form from the json information.

\###[Js ParsleyJS parser](https://github.com/bichotll/Symfony-FormValidationBundle-ParsleyJS-parser)It applies the ParsleyJS validation from the Symfony-FormValidationBundle-js-parser form object or existing one using FormValidationBundle object

\##Wiki

[How to test it](Resources/doc/testing.md)[Full example](Resources/doc/fullExample.md)

\##TODO

- Proper unit test. Until the next change I will not check the responses programatically.
- Unit test using a mock of container, etc.
- Test entity type.

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance15

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity63

Established project with proven stability

 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 ~5 days

Total

8

Last Release

4300d ago

Major Versions

0.9.0 → 1.0.02014-07-01

### Community

Maintainers

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

---

Top Contributors

[![bichotll](https://avatars.githubusercontent.com/u/643359?v=4)](https://github.com/bichotll "bichotll (20 commits)")

---

Tags

validationtwigjavascriptformform validation

### Embed Badge

![Health badge](/badges/bic-form-validation/health.svg)

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

###  Alternatives

[boekkooi/jquery-validation-bundle

Jquery form validation bundle for symfony 2

2773.9k1](/packages/boekkooi-jquery-validation-bundle)[fp/jsformvalidator-bundle

Javascript validation for sf\[2|3|4\] forms.

132418.8k1](/packages/fp-jsformvalidator-bundle)[apy/jsfv-bundle

Symfony2 Javascript Form Validation Bundle with localisation support

92770.5k](/packages/apy-jsfv-bundle)[nucleos/antispam-bundle

This bundle provides some basic features to reduce spam in symfony forms.

52105.1k](/packages/nucleos-antispam-bundle)[egeloen/form-extra-bundle

Provides a JavaScript/StyleSheet fragment for the Symfony Form component.

1080.4k](/packages/egeloen-form-extra-bundle)[craue/formflow-demo-bundle

Example code showcasing the features of CraueFormFlowBundle.

298.5k](/packages/craue-formflow-demo-bundle)

PHPackages © 2026

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