Martyn
Martyn

Reputation: 6383

cakephp access helper from within another helper

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?

Upvotes: 3

Views: 1288

Answers (1)

arilia
arilia

Reputation: 9398

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');
   }
}

Upvotes: 4

Related Questions