Reputation: 3015
I'm trying to populate the select box with countries' timezones. I have seen examples and answers here, but nothing works out for me. I am working on Cakephp 2.3.
My timeZone
helper class is in this directory
App/View/Helper/TimeZoneHelper.php.
Here is my controller:
class TimeZoneController extends AppController{
public function index(){
$helpers = array('TimeZoneHelper');
}
}
my view
<?php
echo $timezone->select('timezone');
?>
It isn't working, and I don't know how it works because I have never used this functionality before.
Upvotes: 0
Views: 363
Reputation: 21743
You are working with cake2.x. But you are using 1.x syntax. The correct syntax for 2.x is:
echo $this->Timezone->select('timezone');
(instead of $timezone-select)
Its also in the documentation by the way: http://book.cakephp.org/2.0/en/views/helpers.html#using-helpers
Upvotes: 1
Reputation: 617
When you want to add helper in action you need to use following code
class TimeZoneController extends AppController{
public function index(){
$this->helpers[] = 'TimeZoneHelper';
}
}
If you want the helper to available to all the action
class TimeZoneController extends AppController{
public $helpers = array('TimeZoneHelper');
public function index(){
}
}
If you want the helper to be available to all controllers then you need to add it to /app/Controller/AppController.php
class AppController extends Controller{
public $helpers = array('TimeZoneHelper');
}
Upvotes: 0