albertcht / invisible-recaptcha

An invisible reCAPTCHA package for Laravel, Lumen, CI or native PHP.
MIT License
603 stars 162 forks source link

Problem with multiform invisible recaptcha #61

Closed babalubas090 closed 6 years ago

babalubas090 commented 6 years ago

Uncaught TypeError: $(...).tooltip is not a function at HTMLDocument. (skyweb.frame.js:32) at j (jquery.min.js:2) at Object.fireWith [as resolveWith] (jquery.min.js:2) at Function.ready (jquery.min.js:2) at HTMLDocument.J (jquery.min.js:2)

When the multiform invisible recaptcha is used, I get this error :/

albertcht commented 6 years ago

Hi @babalubas090 , Which branch are you using? For multi-forms purpose, you should use muliti-forms branch. Also there's a example repo for this branch: https://github.com/albertcht/invisible-recaptcha-example/tree/multi-forms

babalubas090 commented 6 years ago

I'm using the exact branch that you recommends: https://github.com/albertcht/invisible-recaptcha-example/tree/multi-forms But I can't get it working I always get the same error :/

babalubas090 commented 6 years ago

I think that I corrected the issue. I integrated the two branches of your package, the master and the multi-forms. I will make a pull request for the multi-form branch so you can check the correction and let me now if is the write correction.

Note: I think that the error was caused by jQuery library, that you in the script

albertcht commented 6 years ago

Hi @babalubas090 ,

First, thanks for your PR, but basically I keep master and multi-forms separate on purpose, so I will close your pull request. I will check the example repo on multi-forms branch in few days. I will do the bug fix on that branch if I find one.

babalubas090 commented 6 years ago

Sorry, I submitted a wrong fix. I tested after I made the PR, but it didn't work. So I was trying to see if I could fix the problem and I found the solution without integrating the two branches. The problem was that I was calling the jQuerry library in my code and in the file InvisibleReCaptcha.php you are calling the same library too, so I was running the project with two libraries of jQuerry. The solution I found was to do a check if the jQuery library was previously called, so your package would not need to call it again

babalubas090 commented 6 years ago

Sorry for the wrong PR

babalubas090 commented 6 years ago

The solution is just replace the line 105 of src/InvisibleReCaptcha.php for $html = "<script>if ( (typeof jQuery === 'undefined') || !window.jQuery ) { document.write(unescape(\"%3Cscript type='text/javascript' src='" . $this->getJQueryJs() . "'%3E%3C/script%3E\"));}</script>";

albertcht commented 6 years ago

Hi @babalubas090 ,

I'm not sure which commit version you are using. I've removed jquery dependency from InvisibleRecaptcha.php in this commit: https://github.com/albertcht/invisible-recaptcha/commit/ec76a93d35f89c0e5caed395a21f69c8fe7b5c1c#diff-a6b44d29a543635024ad42ccf3fcbcca

So users need to require jquery file before calling this package to prevent from conflict.

babalubas090 commented 6 years ago

I tried to require the multi- form version of your package with composer, but I didn’t get to require. It always says that the version of the package could not be found. So I downloaded the exemple version of the multi form branch, runned the composer install and after it finished the requiring process, I copied the vendor directory of your package to my project. I know that the process that I did wasn’t correct, but was the only way that I could “install” your package on my project.

albertcht commented 6 years ago

Hi @babalubas090 ,

You can install the newest multi-form branch via this command:

composer require albertcht/invisible-recaptcha:dev-multi-forms

I also updated the composer.lock in example repo.

babalubas090 commented 6 years ago

Thank you for your help!

albertcht commented 6 years ago

No problem.

babalubas090 commented 6 years ago

Hi @albertcht I'm with another trouble in my project, I need to change the blade directive of your package because I have another package that calls the same @captcha that your package does. I know that this problem isn't yours package fault, but I need to get it change in my project. It could be @invisibleRecaptcha or another thing. PS: I am not telling you to change your package because of my problem, I only need to change your blade directive call locally.

albertcht commented 6 years ago

Hi @babalubas090 ,

Actually you have other choices rather than blade directives, you can call the render function like this: {!! app('captcha')->render(); !!}. Or you can register your own blade directive in your customized service provider like here: https://github.com/albertcht/invisible-recaptcha/blob/master/src/InvisibleReCaptchaServiceProvider.php#L18-L20

babalubas090 commented 6 years ago

Thank you @albertcht!!!

garbinmarcelo commented 6 years ago

@babalubas090 Were you able to use multiple forms on the same page?