dev-master
9999999-devAllow to get Symfony 2 form server-side validation on a field type
MIT
The Requires
- php >=5.3.2
- symfony/form >2.1
by Alain Bangoula
by RĂ©mi Barbe
Allow to get Symfony 2 form server-side validation on a field type
A symfony 2 bundle integration of wonderful client-side javascript library Parsley.js by @guillaumepotier., (*1)
The ParsleyjsServerBundle allows to get Symfony 2 form server-side validation on a field type via form validations., (*2)
It uses the data-remote attribute of client-side Parsley.js library. For more informations see here., (*3)
Add ParsleyJsServerBundle to your project:, (*4)
$ php composer.phar require mysportconnect/parsley-server-bundle $ php composer.phar update
Add the bundle to your AppKernel.php file:, (*5)
class AppKernel extends Kernel { public function registerBundles() { $bundles = array( // Your bundles new Parsley\ServerBundle\ParsleyServerBundle() );
Add configuration to your config.yml file. As ParsleyJsServerBundle depends on your form validations, not your entities, you must provide information on each form there is a field you want to "remote-validate". You doing this by providing validation_groups for your forms:, (*6)
parsley_server: validations: fos_user_registration: { group: [Registration], translation_domain: validators} fos_user_profile: { group: [Profile], translation_domain: validators}
Then add routing information to your routing.yml file:, (*7)
parsley: resource: "@ParsleyServerBundle/Resources/config/routing.yml" prefix: /parsley
Finally enable Parsley validation on the field you want to like this:, (*8)
public function buildForm ( FormBuilderInterface $builder , array $options ) { $builder -> add ( 'username' , null , array ( "parsley" => true ) ) }
IRC on irc.freenode.net #mysportconnect, (*9)
ParsleyjsServerBundle is licensed under the MIT license (see LICENSE.md file)., (*10)
mySportConnect, Alain Bangoula (aka comensee), RĂ©mi Barbe (aka Remiii) and contributors., (*11)
For bug reports open a Github ticket. Patches gratefully accepted. :-), (*12)
Allow to get Symfony 2 form server-side validation on a field type
MIT