CakePHP Custom Helper not working -
my first time creating custom helper. i'm getting error in controller code i"m calling a method on non existed object (helper). yet believe helper "bm" beingness loaded because i'm not getting errors on loading helpers.
error: phone call fellow member function mcpgetactivemerchantid() on non-object file: c:\wamp\www\bm\app\controller\mcpcontroller.php line: 412 i have placed bmhelper.php view\helper\ directory.
<?php class bmhelper extends apphelper{ public function mcpgetactivemerchant(){ homecoming $this->session->read('auth.activemerchant'); } public function mcpgetactivemerchantid() { $activemerchant = $this->session->read('auth.activemerchant'); foreach($activemerchant $key => $value) { $merchant_id = $key; } homecoming $merchant_id; } } ?> then in controller have this:
<?php class mcpcontroller extends appcontroller { public $helpers = array('html', 'form', 'session','bm','js' => array('jquery')); public function walkinadd() { $test = $this->bm->mcpgetactivemerchantid(); //line 412 } } ?> here error 1 time again (same error pasted @ top)
error: phone call fellow member function mcpgetactivemerchantid() on non-object file: c:\wamp\www\bm\app\controller\mcpcontroller.php line: 412 anyone know wrong?
helpers used in views not controllers, though do:
public function walkinadd() { $view = new view($this); $bm = $view->loadhelper('bm'); $test = $bm->mcpgetactivemerchantid(); } cakephp helper
No comments:
Post a Comment