Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/acseo/formjsvalidationbundle

Symfony Form Js Validation Bundle
https://github.com/acseo/formjsvalidationbundle

form-validation symfony symfony-bundle

Last synced: about 1 month ago
JSON representation

Symfony Form Js Validation Bundle

Awesome Lists containing this project

README

        

# ACSEO Form JS Validation Bundle

A bundle that add js validation to you forms

## Installation

1) Install using composer

```
composer require acseo/form-js-validation-bundle
```

2) Update AppKernel.php :

```php
createForm(AwesomeEntityType::class, $awesomeEntity,array(
'action' => $this->generateUrl('awesomeentity_new'),
'method' => 'POST')
);

// ...
$form = $this->get("acseo_form_js_validation.service")->addJsValidation($form);
// ...
```

### Update templates

#### Using form validation.io

1) In your base template, use formvalidation js and css : http://formvalidation.io/getting-started/#usage

2) In the template when the form is used, just update the code with this :

```twig

{{ form_start(form, {'attr': { 'id' : 'awesome_entity_form', 'data-fv-framework' : 'bootstrap', }}) }}

{{ form_end(form)}}

$(document).ready(function() {
$('#awesome_entity_form').formValidation();
});

```

#### Using form jqueryvalidation.org

1) In your base template, use jqueryvalidation js and css : https://github.com/jquery-validation/jquery-validation/releases

2) In the template when the form is used, just update the code with this :

```twig

{{ form_start(form, {'attr': {'id': 'awesome_entity_form'}}) }}

{{ form_end(form)}}

$(document).ready(function() {
$('#awesome_entity_form').validate();
});

```