Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cakephp access helper from within another helper

Tags:

cakephp

how do I access another helper (e.g. FormHelper) from with a new helper method I've built?

class AppHelper extends Helper {
    public function generateSpecialInput() {
        return $this->Form->input('I\'m special')
    }
}

In the above example, Form is the helper I want to use from within my AppHelper::generateSpecialInput method. Should I be passing the FormHelper object into the method, or is there a better way to do it?

like image 326
Martyn Avatar asked Jan 18 '26 05:01

Martyn


1 Answers

see http://book.cakephp.org/2.0/en/views/helpers.html#including-other-helpers

class AppHelper extends Helper {

public $helpers = array('Form'); 

   public function generateSpecialInput() {
       return $this->Form->input('I\'m special');
   }
}
like image 71
arilia Avatar answered Jan 21 '26 00:01

arilia