Hello.

This seems simple, but I can't make it work (path issue). I'm experimenting
with Zend_Form, and I want to add a custom validator to a form field.

I have written the a test validator and saved it as follows:

I have saved the file as /My/Validate/TestVal.php.

I have a script that builds the form:

<?php 

class forms_ContactForm extends Zend_Form
{
   public function __construct($options = null)
   {
      parent::__construct($options);
      
      $this->addElementPrefixPath('My_Validate','My/Validate/','validate');
      
      $testing = new Zend_Form_Element_Text('testing');
      $testing->setLabel('Title')
         ->setRequired(true);

      $validators = $testing->getValidators();
      $testval   = array('validator' => 'TestVal');
      array_unshift($validators, $testval);
      
      $testing->setValidators($validators);
            
      //etc...
   }
}

This fails at $testing->setValidators with the following message...

Error: Plugin by name My_Validate_TestVal was not found in the registry.

How to get the custom validator attached to the element? 

Thanks.

Sam



-- 
View this message in context: 
http://www.nabble.com/custom-form-validator-tp16628634p16628634.html
Sent from the Zend Framework mailing list archive at Nabble.com.

Reply via email to