1

I am working in a ZF 1.12.x project and I am adding a new custom helper stored at: /application/views/helpers/MyFormText.php (also tried with name View_Helper_MyFormText):

The content of the helper so far is simple as:

class MyFormText extends Zend_View_Helper_FormText
{
    public function MyFormText($name, $value = null, $attribs = null)
    {
        // @TODO: check if the component can be rendered on the view
        return parent::formText($name, $value, $attribs);
    }
}

As soon as I access the page I end with this error:

[message:protected] => Plugin by name 'MyFormText' was not found in the registry; used paths: Zend_View_Helper_: Zend/View/Helper/:./../application/views/helpers/

Is weird that apparently this path:

 Zend_View_Helper_: Zend/View/Helper/:./../application/views/helpers/

Is used for look the helpers but even though the class can't be loaded. I have read and tried all of these:

What I am doing wrong? Can any give me some help on this? I am stuck

Community
  • 1
  • 1
ReynierPM
  • 17,594
  • 53
  • 193
  • 363
  • Try printing the helper path/s. From a view, you can var_dump($this). You can register paths using `Zend_View::addHelperPath`. – Progrock Nov 17 '16 at 21:46
  • @Progrock I am not seeing the path loaded so maybe isn't registered. Although I can see it on the error `Zend_View_Helper_: Zend/View/Helper/:./../application/views/helpers/`. Can you write a small example for me? – ReynierPM Nov 17 '16 at 21:49
  • 1
    In application.ini -> `resources.view.helperPath.Your_View_Helper_Class_Prefix = APPLICATION_PATH "/views/helpers"` – Progrock Nov 17 '16 at 21:58
  • @Progrock thanks for your time, I have found the answer and reply myself – ReynierPM Nov 17 '16 at 22:01
  • Your view helper normally extends `Zend_View_Helper_Abstract`, and your name might be something like: `ReynierPM_MyFormText`. – Progrock Nov 17 '16 at 22:01

1 Answers1

0

I have found my answer here.

By default, the class is prefixed with 'Zend_View_Helper_' (you can specify a custom prefix when setting a helper path), and the last segment of the class name is the helper name; this segment should be TitleCapped; the full class name is then: Zend_View_Helper_FooBar. This class should contain at the minimum a single method, named after the helper, and camelCased: fooBar().

So by changing the class name from MyFormText to Zend_View_Helper_MyFormText make it to works.

ReynierPM
  • 17,594
  • 53
  • 193
  • 363