Sorry for the inconvenience.

it was an error in the validator code itself that prevented correct
execution.

somehow i used '<%php' as the script token instead of '<?php'

what a fool i am. :,(

kim



KimG wrote:
> 
> Hi,
> 
> i'm running the Zend v 1.8.? and i have a problem regarding validators. I
> can't get them to load.
> 
> i think i've double checked everything but it still fails to work. Please
> help me out.
> 
> I've read the other posts in this forum where people seem to have the same
> problem. but no matter what i try it doesn't help.  I've tried to
> addprefixpath on the loader, add elementprefixpath on the form and
> addprefixpath on the element. but nothing works.
> 
> is it a path problem or what? i've read chap 30 (IIRC) in the zend manual
> about the Loader and i think i've followed the rules.
> 
> My include path is like this:
> 
> /var/www/pimp/application:/var/www/pimp/library::.:/usr/share/Zend/library:/usr/local/outlet-0.7/classes/outlet
> 
> my directory structure is like this:
> 
> var
>    www
>       pimp
>          application
>             configs
>             controllers
>             forms
>             and so on
>         library 
>            Pimp
>               Validate
>                   Authorise.php (file)
> 
> and everything works fine. it loads forms and views and finds controllers.
> nice.
> 
> but when i want to assign a custom validator to a field in my form i
> receive an error message:
> 
> -----------
> 
>  Message: Plugin by name 'Authorise' was not found in the registry; used
> paths: Pimp_Validate_: Pimp/Validate/:Pimp/Validate/ Zend_Validate_:
> Zend/Validate/
> Stack trace:
> 
> #0 /usr/share/Zend/library/Zend/Form/Element.php(1992):
> Zend_Loader_PluginLoader->load('Authorise')
> #1 /usr/share/Zend/library/Zend/Form/Element.php(1211):
> Zend_Form_Element->_loadValidator(Array)
> #2 /usr/share/Zend/library/Zend/Form/Element.php(1295):
> Zend_Form_Element->getValidators()
> 
> ----------
> 
> when submiting the form.
> 
> 
> My form look like this:
> 
> 
> 
> --------------------
> 
> <?php
> //var_dump(set_include_path('./'));
> 
> //include_once 'Zend/Form.php';
> 
> class Form_Login extends Zend_Form{
>   
>   public function __construct($options = null){
>     parent::__construct($options);
>     
>     
> //    $loader = new Zend_Loader_PluginLoader();
> //    $loader->addPrefixPath('Pimp_Validate', 'Pimp/Validate/');
>     
>     $this->setMethod('post');
>     $this->setAttrib('class','zend_form');
>     $username=$this->CreateElement('text','username')->setLabel('User
> Name:');
>     $username->setDecorators(array(
>                                    'ViewHelper',
>                                    'Description',
>                                    'Errors',
>                                    array(array('data'=>'HtmlTag'), 
>                                    array('tag' => 'td')),
>                                    array('Label', array('tag' => 'td')),
>                                   
> array(array('row'=>'HtmlTag'),array('tag'=>'tr')
>                              )));
> 
>     
> //    $this->addElementPrefixPath('Pimp_Validate', 'Pimp/Validate/',
> 'validate');
>    
> $username->addValidator('alnum')->setRequired(true)->addValidator('NotEmpty',
> true)->addFilter('StringTrim');
>     $username->addPrefixPath('Pimp_Validate', 'Pimp/Validate/',
> 'validate');
>     $username->addValidator('Authorise');
>     $username->getValidator('alnum')->setMessage('Only letters and numbers
> are allowed in username');
>     $username->getValidator('NotEmpty')->setMessage('Username cannot be
> empty');
> 
> 
>    
> $password=$this->CreateElement('password','password')->setLabel('Password:');
>     $password->setDecorators(array(
>                                    'ViewHelper',
>                                    'Description',
>                                    'Errors',
>                                    array(array('data'=>'HtmlTag'),
> array('tag' => 'td')),
>                                    array('Label', array('tag' => 'td')),
>                                   
> array(array('row'=>'HtmlTag'),array('tag'=>'tr'))
>                               ));
>    
> $password->addValidator('alnum')->setRequired(true)->addValidator('NotEmpty',
> true)->addFilter('StringTrim')->addValidator('stringLength', true,
> array(6));
>     $password->getValidator('stringLength')->setMessage('Password is too
> short');
>     $password->getValidator('NotEmpty')->setMessage('Password cannot be
> empty');
> 
>     $submit=$this->CreateElement('submit','submit')->setLabel('Login');
>     $submit->setAttrib('class', 'submit_log');
> 
>     $submit->setAttrib('onmouseout', 'MM_swapImgRestore()');
>     $submit->setAttrib('onmouseover',
> "MM_swapImage('images/btn-register','','images/btn-register_on.png',1)");
>     
>     $submit->setDecorators(array(
>                                  'ViewHelper',
>                                  'Description',
>                                  'Errors', 
>                                  array(array('data'=>'HtmlTag'),
> array('tag' => 'td')),
>                                 
> array(array('row'=>'HtmlTag'),array('tag'=>'tr', 'openOnly'=>'true'))
> 
>                            ));
> 
>    
> $register=$this->CreateElement('submit','register')->setLabel('Register');
>     $register->setAttrib('class', 'submit_reg');
>     $register->setDecorators(array(
>                                  'ViewHelper',
>                                  'Description',
>                                  'Errors', 
>                                  array(array('data'=>'HtmlTag'),
> array('tag' => 'td')),
>                                 
> array(array('row'=>'HtmlTag'),array('tag'=>'tr', 'closeOnly'=>'true'))
> 
>                            ));
> 
>        $this->addElements(array(
>                              $username,
>                              $password,
>                              $submit,
>                              $register
>                        ));
> 
>     $this->setDecorators(array(
>                                'FormElements',
>                               
> array(array('data'=>'HtmlTag'),array('tag'=>'table')),
>                                'Form'
>                          ));
> 
>   }
> }
> ?>
> 
> 
> --------------------       
> 
> my validator looks like this:
> 
> 
> -------------
> 
> <%php
> 
>   class Pimp_Validate_Authorise extends Zend_Validate_Abstract{
>     const NOT_AUTHORISED = 'notAuthorised';
>     
>     public function isValid($value, $context=null){
>       return true;
>     }
>       
>   }
>   
> 
> 
> %>
> 
> -------------
> 
> 
> it's located in var/www/pimp/library/Pimp/Validate/Autorise.php
> 
> what am I doing wrong?
> 
> any help appreciated and thanx in advance.
> 
> kim
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Cannot-get-validator-to-load-tp23888565p23889356.html
Sent from the Zend Framework mailing list archive at Nabble.com.

Reply via email to