Solving CK Forms mootools.js Issue

Don't you just hate it when you finally found a great extension, and it has an issue in it that gives errors and make your pages act all weird?

I had this issue with CK Forms, and by the looks of it, the same issue was a problem for lots of people.

 

The Problem

When you use the CK Forms form plugin on a page, showing a contact form, the browser comes up with a mootools.js error. The form works, but it still shows 'error' in the footer of the browser (not so nice for your visitors) and other elements using mootools start behaving weird as well.

The problem I had with one site was that the fusionmenu dropdown boxes (I was using a Rockettheme template) could not be clicked on the page the form was on.

It took me quite some searching, but I finally found the answer!

 

The Solution

Apparently CK Forms calls mootools.js, even when it is already called in the page. The solution is commenting out the mootools.js call in the CK Forms PHP files. When you only use the Form Display plugin and the component, like most do, there are two files that need edition:

  • components/com_ckforms/views/ckforms/view.html.php
    • comment out the following line:
      $document->addCustomTag('<script type="text/javascript" src="'.JURI::root(true).'/media/system/js/mootools.js"></script>');

      so it looks like:
      /** $document->addCustomTag('<script type="text/javascript" src="'.JURI::root(true).'/media/system/js/mootools.js"></script>'); */

      Don't forget to close the comment with */, or errors will occur

  • plugins/content/ckforms.php
    • comment out the following line:
      $html = $html.'<script type="text/javascript" src="'.JURI::root(true).'/media/system/js/mootools.js"></script>'."\n";

      so it looks like:
      /** $html = $html.'<script type="text/javascript" src="'.JURI::root(true).'/media/system/js/mootools.js"></script>'."\n"; */

      Don't forget to close the comment with */, or errors will occur

 

Now mootools.js will not be called by CK Forms anymore, resulting in error-free pages!

_____________________________________________________________________________________________

Robin Roelofsen

"I think complexity is mostly sort of crummy stuff that is there because it's too expensive to change the interface."
Jaron Lanier

Bookmark and Share

2 comments to Solving CK Forms mootools.js Issue

  • Dezso MarkonNo Gravatar

    Well done!
    Thanks for sharing this, I was about to change my form component when I came across your post. It works!

  • NateNo Gravatar

    Thank You Thank You Thank You!

    Ive spent the last two days trying to get rid of IE warnings for our forms that use SSL. I had to enable the new mootools upgrade to finally stop the warnings…Which broke K2 Items pages that had a ckform (all 120 of em) … What a nightmare… Your solution worked perfectly!
    Thank you!

Leave a Reply

  

  

  

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <font color="" face="" size=""> <span style="">