【问题标题】:cakephp access helper from within another helpercakephp 从另一个助手中访问助手
【发布时间】:2014-03-11 06:18:56
【问题描述】:

如何使用我构建的新帮助方法访问另一个帮助程序(例如 FormHelper)?

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

在上面的例子中,Form 是我想在我的 AppHelper::generateSpecialInput 方法中使用的助手。我应该将 FormHelper 对象传递给方法,还是有更好的方法?

【问题讨论】:

    标签: cakephp


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 2013-06-18
      • 2015-03-28
      • 2014-09-26
      • 1970-01-01
      • 2016-09-02
      • 1970-01-01
      • 2015-01-29
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多