All Projects → formapro → Jsformvalidatorbundle

formapro / Jsformvalidatorbundle

Licence: mit
The Javascript validation for Symfony 2, 3 and 4 forms

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Jsformvalidatorbundle

Vichuploaderbundle
A simple Symfony bundle to ease file uploads with ORM entities and ODM documents.
Stars: ✭ 1,613 (+1140.77%)
Mutual labels:  bundle, symfony
Sonataseobundle
Symfony SonataSeoBundle
Stars: ✭ 106 (-18.46%)
Mutual labels:  bundle, symfony
Easy Doc Bundle
Symfony application documentation generator
Stars: ✭ 99 (-23.85%)
Mutual labels:  bundle, symfony
Web Server Bundle
WebServerBundle provides commands for running applications using the PHP built-in web server. It simplifies your local development setup because you don't have to configure a proper web server such as Apache or Nginx to run your application.
Stars: ✭ 1,281 (+885.38%)
Mutual labels:  bundle, symfony
Crauegeobundle
Doctrine functions for calculating geographical distances in your Symfony project.
Stars: ✭ 112 (-13.85%)
Mutual labels:  bundle, symfony
Swarrotbundle
A symfony bundle for swarrot integration
Stars: ✭ 89 (-31.54%)
Mutual labels:  bundle, symfony
Notification Bundle
A simple Symfony bundle to notify user
Stars: ✭ 103 (-20.77%)
Mutual labels:  bundle, symfony
Twigextensionsbundle
Useful Twig extensions for your Symfony project.
Stars: ✭ 75 (-42.31%)
Mutual labels:  bundle, symfony
Passwordstrengthbundle
Symfony Password strength and blacklisting validator bundle
Stars: ✭ 123 (-5.38%)
Mutual labels:  bundle, symfony
Liipimaginebundle
Symfony Bundle to assist in imagine manipulation using the imagine library
Stars: ✭ 1,516 (+1066.15%)
Mutual labels:  bundle, symfony
Pugxautocompleterbundle
Add an autocomplete field to your Symfony forms
Stars: ✭ 83 (-36.15%)
Mutual labels:  bundle, symfony
Swiftmailer Bundle
Symfony Swiftmailer Bundle
Stars: ✭ 1,558 (+1098.46%)
Mutual labels:  bundle, symfony
Knpmenubundle
Object Oriented menus for your Symfony project.
Stars: ✭ 1,242 (+855.38%)
Mutual labels:  bundle, symfony
Easy Security Bundle
EasySecurityBundle
Stars: ✭ 95 (-26.92%)
Mutual labels:  bundle, symfony
Sonataclassificationbundle
Symfony SonataClassificationBundle
Stars: ✭ 76 (-41.54%)
Mutual labels:  bundle, symfony
Filemanagerbundle
FileManager is a simple Multilingual File Manager Bundle for Symfony
Stars: ✭ 105 (-19.23%)
Mutual labels:  bundle, symfony
Neo4j Symfony
Symfony Bundle for the Neo4j Graph Database
Stars: ✭ 69 (-46.92%)
Mutual labels:  bundle, symfony
Cronos Bundle
Easy update your crontab by using @cron annotations in Symfony commands.
Stars: ✭ 73 (-43.85%)
Mutual labels:  bundle, symfony
Liipcachecontrolbundle
DEPRECATED! This bundle is superseded by FOSHttpCacheBundle. A migration guide is in the README of LiipCacheControlBundle
Stars: ✭ 108 (-16.92%)
Mutual labels:  bundle, symfony
Nelmiocorsbundle
The NelmioCorsBundle allows you to send Cross-Origin Resource Sharing headers with ACL-style per-URL configuration.
Stars: ✭ 1,615 (+1142.31%)
Mutual labels:  bundle, symfony

FpJsFormValidatorBundle

Build Status Total Downloads

This module enables validation of the Symfony 4 or later forms on the JavaScript side. It converts form type constraints into JavaScript validation rules.

If you have Symfony 4.* - you need to use Version 1.6.x-dev

If you have Symfony 3.1.* - you need to use Version 1.5.*

If you have Symfony 3.0.* - you need to use Version 1.4.*

If you have Symfony 2.8.* or 2.7.* - you need to use Version 1.3.*

If you have Symfony 2.6.* or less - you need to use Version 1.2.*

1 Installation

1.1 Download FpJsFormValidatorBundle using composer

Run in terminal:

$ composer require "fp/jsformvalidator-bundle":"dev-master"

Or if you do not want to unexpected problems better to use exact version.

$ composer require "fp/jsformvalidator-bundle":"v1.6.*"

1.2 Enable javascript libraries

There are two ways to initialize javascript's files for this library. You can create a new entry in the webpack or import the main file into your javascript.

1.2.1 Add FpJsFormValidatorBundle to webpack.config.js

Encore
    ...
    .addEntry('app', './assets/js/app.js')
+   .addEntry('FpJsFormElement', './vendor/fp/jsformvalidator-bundle/Fp/JsFormValidatorBundle/Resources/public/js/FpJsFormValidatorWithJqueryInit.js')
    ...
    .configureBabel(null, {
        useBuiltIns: 'usage',
        corejs: 3,
    })
;

And include new entry in your template

+   {{ encore_entry_script_tags('FpJsFormElement') }}
    {{ encore_entry_script_tags('app') }}

1.2.2 Import FpJsFormValidatorBundle in your main javascript

  import $ from 'jquery';
+  import 'path-to-bundles/fpjsformvalidator/js/FpJsFormValidator';
+  import 'path-to-bundles/fpjsformvalidator/js/jquery.fpjsformvalidator';

1.2.3 Use inits in your template

{% block javascripts %}
+   {{ js_validator_config() }}
+   {{ init_js_validation() }}
{% endblock %}

1.4 Add routes

If you use the UniqueEntity constraint, then you have to include the next part to your routing config: app/config/routing.yml

# ...
fp_js_form_validator:
    resource: "@FpJsFormValidatorBundle/Resources/config/routing.xml"
    prefix: /fp_js_form_validator

Make sure that your security settings do not prevent these routes.

2 Usage

After the previous steps the javascript validation will be enabled automatically for all your forms.

  1. Disabling validation
  2. If your forms are placed in sub-requests
  3. If you need to initialize JS validation for your forms separately, or by some event, in this case you need to follow chapter 1.3

3 Customization

Preface

This bundle finds related DOM elements for each element of a symfony form and attach to it a special object-validator. This object contains list of properties and methods which fully define the validation process for the related form element. And some of those properties and methods can be changed to customize the validation process.

If you render forms with a some level of customization - read this note.

  1. Disable validation for a specified field
  2. Error display
  3. Get validation groups from a closure
  4. Getters validation
  5. The Callback constraint
  6. The Choice constraint. How to get the choices list from a callback
  7. Custom constraints
  8. Custom data transformers
  9. Checking the uniqueness of entities
  10. Form submit by Javasrcipt
  11. onValidate callback
  12. Run validation on custom event
  13. Collections validation
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].