formapro / JsFormValidatorBundle

The Javascript validation for Symfony 2, 3 and 4 forms
MIT License
128 stars 57 forks source link

'No route found for "GET /bundles/fpjsformvalidator/js/fp_js_validator.js"' (since update to 1.3.*) #109

Closed tkurze closed 5 years ago

tkurze commented 8 years ago

Hi,

I recently updated to symfony 2.8.(4) and JsFormValidatorBundle 1.3.* (before I used JsFormValidatorBundle 1.2.1) (also updated some other packages too...). Now I'm getting 'No route found for "GET /bundles/fpjsformvalidator/js/fp_js_validator.js"' (but: GET /bundles/fpjsformvalidator/js/FpJsFormValidator.js works fine.) Before the updates (and - admittedly - few other changes) everything worked fine

I checked on my test system (where I did not yet update the packages) and in vendor/fp/jsformvalidatorbundle/..../Resources/public/js there still is a file called "fp_js_validator.js".

On my updated system this file does not exist anymore! Also in the JsFormValidatorBundle-git repository the file exists in Release 1.0.2 (which I might have used a while ago), but I couldn't find it in branches 1.2 nor 1.3.

Is that on purpose? Does this file get generated in some way? I have {{ include('FpJsFormValidatorBundle::javascripts.html.twig') }} in my template(s) - which in turn references: {{ asset('bundles/fpjsformvalidator/js/fp_js_validator.js') }} - but this file does not exist anymore.

What am I missing?

Thanks for your help! Best regards, Tobias

abienvenu commented 8 years ago

This looks like a build issue. fp_js_validator.js is generated when running dev/test. It should be included in the composer package. It was present in v1.2.1, but it is missing from 1.4.*

tkurze commented 8 years ago

Hey, thanks a lot for your help. I'll check if something goes wrong during dev/test. Tobias

tkurze commented 8 years ago

Hi, actually I'm not sure if I got you right: Should 'fp_js_validator.js' already be included in the composer package, i.e. composer should simply just put it in the corresponding directory OR should it be created after retrieval by composer by running dev/test? In the first case -> the file is missing - at least for me :(

[more or less unrelated] I tried to run the unit tests but somehow the test / selenium server crashes my X-Server ... [/more or less unrelated]

abienvenu commented 8 years ago

It should be included in the composer package. @66Ton99 is working on it.

tkurze commented 8 years ago

cool, thanks :)

66Ton99 commented 8 years ago

fp_js_validator.js - contains compiled code from FpJsFormValidator.js and transformers/* I was able to reproduce the problem but did not able to solve it.

ghost commented 8 years ago

Hi,

I have the Same issue with Symfony 3.0.* and try to user JsFormValidator on dev-master or 1.4.*.

Error > No route found for "GET /bundles/fpjsformvalidator/js/fp_js_validator.js

I have check on /public/ and unfortunately i already have FpJsFormValidator.js but not fp_js_validator.js.

If i have understood, fp_js_validator.js should be automaticaly generated when we run composer update ? Si if it's that, when you think you can correct the build ?

66Ton99 commented 8 years ago

Unfortunately I do not have time now but PRs are welcome.

xeroxzone commented 8 years ago

Short workaround:

If you are using symfony with assetic you can make:

js_form_validation:
    inputs:
        - "%kernel.root_dir%/../vendor/fp/jsformvalidator-bundle/Fp/JsFormValidatorBundle/Resources/public/js/FpJsFormValidator.js"
        - "%kernel.root_dir%/../vendor/fp/jsformvalidator-bundle/Fp/JsFormValidatorBundle/Resources/public/js/constraints/*"
        - "%kernel.root_dir%/../vendor/fp/jsformvalidator-bundle/Fp/JsFormValidatorBundle/Resources/public/js/transformers/*"
    output: "bundles/fpjsformvalidator/js/fp_js_validator.js"

and create the "bundles/fpjsformvalidator/js/fp_js_validator.js" as new asset

maryo commented 8 years ago

@66Ton99 The compiled file is listed in .gitignore since this commit so even the file is probably generated well when running tests (strange workflow), it couldn't be part of any commit since then :)

https://github.com/formapro/JsFormValidatorBundle/commit/ea25475f1a2a5382325254e0167bc4619e256f99

I am not sure what was the exact reason for the change but I guess that's the only issue. Perhaps you wanted to ignore Tests/app/js/fp_js_validator.js instead? But maybe not, just guessing.

Growiel commented 7 years ago

What's the status of this ? I tried to install this nodule and i'm faced with the same issue.

I do not use Assetic so I can't re-generate the file using javascripts-dev.html.twig.

bastos71 commented 7 years ago

hi guys ! Thx to @66Ton99 I found a solution to make all work :

Define the assetic to compile FpJSFormValidator js :

#app/config/config.yaml
assetic:
    bundles:
        - AcmeDefaultBundle

And wherever you want to load the javascripts sources

{% javascripts
        '@FpJsFormValidatorBundle/Resources/public/js/FpJsFormValidator.js'
        '@FpJsFormValidatorBundle/Resources/public/js/constraints/Blank.js'
        '@FpJsFormValidatorBundle/Resources/public/js/constraints/Callback.js'
        '@FpJsFormValidatorBundle/Resources/public/js/constraints/Choice.js'
        '@FpJsFormValidatorBundle/Resources/public/js/constraints/Count.js'
        '@FpJsFormValidatorBundle/Resources/public/js/constraints/Date.js'
        '@FpJsFormValidatorBundle/Resources/public/js/constraints/DateTime.js'
        '@FpJsFormValidatorBundle/Resources/public/js/constraints/Email.js'
        '@FpJsFormValidatorBundle/Resources/public/js/constraints/EqualTo.js'
        '@FpJsFormValidatorBundle/Resources/public/js/constraints/GreaterThan.js'
        '@FpJsFormValidatorBundle/Resources/public/js/constraints/GreaterThanOrEqual.js'
        '@FpJsFormValidatorBundle/Resources/public/js/constraints/IdenticalTo.js'
        '@FpJsFormValidatorBundle/Resources/public/js/constraints/Ip.js'
        '@FpJsFormValidatorBundle/Resources/public/js/constraints/IsFalse.js'
        '@FpJsFormValidatorBundle/Resources/public/js/constraints/False.js'
        '@FpJsFormValidatorBundle/Resources/public/js/constraints/IsNull.js'
        '@FpJsFormValidatorBundle/Resources/public/js/constraints/IsTrue.js'
        '@FpJsFormValidatorBundle/Resources/public/js/constraints/Length.js'
        '@FpJsFormValidatorBundle/Resources/public/js/constraints/LessThan.js'
        '@FpJsFormValidatorBundle/Resources/public/js/constraints/LessThanOrEqual.js'
        '@FpJsFormValidatorBundle/Resources/public/js/constraints/NotBlank.js'
        '@FpJsFormValidatorBundle/Resources/public/js/constraints/NotEqualTo.js'
        '@FpJsFormValidatorBundle/Resources/public/js/constraints/NotIdenticalTo.js'
        '@FpJsFormValidatorBundle/Resources/public/js/constraints/NotNull.js'
        '@FpJsFormValidatorBundle/Resources/public/js/constraints/Null.js'
        '@FpJsFormValidatorBundle/Resources/public/js/constraints/Range.js'
        '@FpJsFormValidatorBundle/Resources/public/js/constraints/Regex.js'
        '@FpJsFormValidatorBundle/Resources/public/js/constraints/Time.js'
        '@FpJsFormValidatorBundle/Resources/public/js/constraints/True.js'
        '@FpJsFormValidatorBundle/Resources/public/js/constraints/Type.js'
        '@FpJsFormValidatorBundle/Resources/public/js/constraints/UniqueEntity.js'
        '@FpJsFormValidatorBundle/Resources/public/js/constraints/Url.js'
        '@FpJsFormValidatorBundle/Resources/public/js/constraints/Valid.js'
        '@FpJsFormValidatorBundle/Resources/public/js/transformers/*'
        output="js/fp_js_formvalidator.js" %}
        <script src="{{ asset_url }}"></script>
{% endjavascripts %}
{{ js_validator_config() }}
{{ init_js_validation() }}

@xeroxzone I could not load automatically @FpJsFormValidatorBundle/Resources/public/js/constraints/* because False.js depends on isFalse.js

After this everything worked perfectly :)

Edit

And here is and javascript file generated : fp_js_formvalidator.zip

You can simply put it in your app bundle public Resources and include this code to your template :

<script src="{{ asset('bundles/appbundle/js/fp_js_formvalidator.js') }}"></script>
{{ js_validator_config() }}
{{ init_js_validation() }}
66Ton99 commented 7 years ago

@bastos71 thank you! May be can we put it here https://github.com/formapro/JsFormValidatorBundle/blob/master/Resources/views/javascripts.html.twig?

bastos71 commented 7 years ago

@66Ton99 you're welcome ! Yes that's the idea, for the moment i put it in my own fp_jsformvalidator.html.twig inside my AppBundle, waiting for a new release that will fix this issue :)

66Ton99 commented 7 years ago

@bastos71 can you provide PR for master?

bastos71 commented 7 years ago

@66Ton99 do you want me to add only the fp_js_validator.js ? Or do you wand me to add the {% javascripts %} tag ? Because in this case that will force developpers to use assetics :/

66Ton99 commented 7 years ago

assetics already as required dependency

bastos71 commented 7 years ago

Yes but the depedency is in the "require-dev" sectio. May be we should put it in javascripts-dev.html.twig, no ?

bastos71 commented 7 years ago

Created the pull request with all changes #127

66Ton99 commented 7 years ago

@bastos71 thank you! I simplify JS load https://github.com/formapro/JsFormValidatorBundle/blob/master/Resources/views/javascripts.html.twig can you check will it work?

bastos71 commented 7 years ago

@66Ton99 Nope that won't work because constraints/False.js depends on the definition of constraints/isFalse.js. If we simply set @FpJsFormValidatorBundle/Resources/public/js/constraints/*, then False.js will be loaded before isFalse.js and there will be a javascript error in the browser once loaded.

66Ton99 commented 5 years ago

Fixed in https://github.com/formapro/JsFormValidatorBundle/commit/57e6d9fd33e8dd102bfd3651b44831644233650d#diff-d178e68a64d1017a94919009bbbeb609