Troubles with Custom Validation plugin

2 messages Options
Embed this post
Permalink
Kuzma

Troubles with Custom Validation plugin

Reply Threaded More More options
Print post
Permalink
Hi all!
I'm newbie to Zend framework and I've encountered one more problem
So, I've read this tutorial: _http://steven.macintyre.name/zend-framework-jquery-form-validation-plugins/
And I'm getting this error:
exception 'Zend_Loader_PluginLoader_Exception' with message 'Plugin by name 'ValidateText' was not found in the registry
As I understood I must use addPrefixPath function that element should know which validator to use.
So, in this place I'm got in trouble - I don't know how to add prefix at this code:


$this->setAction('/admin/registration/register')
                ->setMethod('post');
                $this->setAttrib('name', 'register');


        $this->addElement(
                        'validateText',
                        'username',
                        array(
                                'label' => 'Username',
                                'formId' => 'register',
                                'trim' => true,
                                'required' => true,
                                'validators'   => array(
                                        array(
                                                'validator' => 'StringLength',
                                                 'options' => array(5, 15)
                                        )
                                ),
                                'js' => array(
                                        'minlength' => '5',
                                        'maxlength' => '15',
                                        'class' => 'required',
                                        'remote' => '/user/ajax/checkuser/',
                                ),
                        )
                );

The dir tree looks like this:

library
    --Ig
        Form->Element->ValidateText.pgp
        View
              Helper->ValidateText.php

Thank you in advance!
Kuzma

Re: Troubles with Custom Validation plugin

Reply Threaded More More options
Print post
Permalink
Forgot to mention, that I'm using this initView method:

        protected function _initViewHelpers()
        {
                 
 
                $view = new Zend_View();
                $view->setEncoding('UTF-8');
               
                $view->doctype('XHTML1_STRICT');
                $view->headScript()->appendFile('/tabmenu/js/jquery-1.3.1.min.js');
               
                $view->addHelperPath("Ig/View/Helper","Ig_View_Helper_")
                ->addHelperPath("Tinymce/View/Helper","Tinymce_View_Helper_")
        ->addHelperPath("ZendX/JQuery/View/Helper", "ZendX_JQuery_View_Helper");
               
                $viewRenderer = new Zend_Controller_Action_Helper_ViewRenderer($view);
               
                $viewRenderer->setView($view);
               
                Zend_Controller_Action_HelperBroker::addHelper($viewRenderer);
               

                Zend_Layout::startMvc(
            array(
                                'layout' => 'layout',
                'layoutPath' => '/application/views/layouts',
            'pluginClass' => 'ZFBlog_Layout_Controller_Plugin_Layout'
            )
        );
       
        $view = Zend_Layout::getMvcInstance()->getView();//?
       
                $this->bootstrap('layout');
                $layout=$this->getResource('layout');
               
               
               
                $config=new Zend_Config_Xml(APPLICATION_PATH . '/configs/navigation.xml', 'nav');
                $navigation=new Zend_Navigation($config);
               
                $view->navigation($navigation)->setAcl($this->_acl)->setRole(Zend_Registry::get('role'));
               
        }

And in initAutoload:
        protected function _initAutoLoad()
        {
                $autoloader = Zend_Loader_Autoloader::getIn
                $autoloader->setFallbackAutoloader(true);
...
}