Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What has happened to javascript helper in cakePHP 2?

I have used this item and get this error :

Missing Helper
Error: JavascriptHelper could not be found.
Error: Create the class JavascriptHelper below in file: app/View/Helper/JavascriptHelper.php
<?php
     class JavascriptHelper extends AppHelper {
 }

Well indeed, this file does not exists, and I tried to use 'Js' in my helper array.

class myClassController expend AppController {
    var $helpers = array('Html', 'Js'); // and not 'Javascript');

In the code, the method $this->Javascript->codeBlock is called to add a javascript method (in the middle of the content instead of the header) but there is no $this->Js->codeBlockcodeBlock either.

$output .= $this->Js->codeBlock("datepick('" . $htmlAttributes['id'] . "','01/01/" . $options['minYear'] . "','31/12/" . $options['maxYear'] . "');");
    

Could you explain me what happened to the old Javascript helper or how to get the code working?

Is there an other helper which could work with CakePHP-2.0?

Cordially,

like image 671
MUY Belgium Avatar asked Aug 21 '12 08:08

MUY Belgium


1 Answers

Have you read the migration guide? If not do that now: http://book.cakephp.org/2.0/en/appendices/2-0-migration-guide.html#xmlhelper-ajaxhelper-and-javascripthelper-removed

XmlHelper, AjaxHelper and JavascriptHelper removed The AjaxHelper and JavascriptHelper have been removed as they were deprecated in version 1.3. The XmlHelper was removed, as it was made obsolete and redundant with the improvements to Xml. The Xml class should be used to replace previous usage of XmlHelper.

The AjaxHelper, and JavascriptHelper are replaced with the JsHelper and HtmlHelper.

JsHelper JsBaseEngineHelper is now abstract, you will need to implement all the methods that previously generated errors.

So

$this->Js->codeBlock('...');

is now

$this->Html->codeBlock('...');
like image 161
floriank Avatar answered Oct 13 '22 11:10

floriank