@@ -26,14 +26,17 @@ Or if you do not want to unexpected problems better to use exact version.
2626$ composer require " fp/jsformvalidator-bundle" :" v1.6.*"
2727```
2828
29- ### 1.2 Enable javascript libraries<a name =" p_1_3 " ></a >
29+ ### 1.2 Enable javascript libraries
30+
31+ There are two ways to initialize javascript's files for this library.
32+ You can create a new entry in the webpack or import the main file into your javascript.
3033
3134#### 1.2.1 Add FpJsFormValidatorBundle to webpack.config.js
3235``` diff
3336Encore
3437 ...
35- .addEntry('search ', './assets/js/search .js')
36- + .addEntry('FpJsFormElement', './vendor/fp/jsformvalidator-bundle/Fp/JsFormValidatorBundle/Resources/public/js/FpJsFormValidator .js')
38+ .addEntry('app ', './assets/js/app .js')
39+ + .addEntry('FpJsFormElement', './vendor/fp/jsformvalidator-bundle/Fp/JsFormValidatorBundle/Resources/public/js/FpJsFormValidatorWithJqueryInit .js')
3740 ...
3841 .configureBabel(null, {
3942 useBuiltIns: 'usage',
@@ -42,15 +45,24 @@ Encore
4245;
4346```
4447
45- #### 1.3.2 Include the javascripts to your template
48+ And include new entry in your template
4649``` diff
47- {% block javascripts %}
48- {{ encore_entry_script_tags('app') }}
4950+ {{ encore_entry_script_tags('FpJsFormElement') }}
51+ {{ encore_entry_script_tags('app') }}
52+ ```
5053
54+ #### 1.2.2 Import FpJsFormValidatorBundle in your main javascript
55+ ``` diff
56+ import $ from 'jquery';
57+ + import 'path-to-bundles/fpjsformvalidator/js/FpJsFormValidator';
58+ + import 'path-to-bundles/fpjsformvalidator/js/jquery.fpjsformvalidator';
59+ ```
60+
61+ #### 1.2.3 Use inits in your template
62+ ``` diff
63+ {% block javascripts %}
5164+ {{ js_validator_config() }}
5265+ {{ init_js_validation() }}
53-
5466{% endblock %}
5567```
5668
0 commit comments