Search Results

Search found 1 results on 1 pages for 'remlabm'.

Page 1/1 | 1 

  • Zend Framework Custom Validation Class Error Message

    - by remlabm
    The validation fails as it should but does not return the error message. $form->addElement('text', 'phone_number', array( 'required' => true, 'validators' => array( array('NotEmpty', true, array('messages' => 'Enter a valid Phone Number')), array('regex', false, array('pattern' => '/\([0-9]{3}\)\s[0-9]{3}-[0-9]{4}/', 'messages' => 'Enter a valid Phone Number' )), 'CheckPhoneNumber'), ), )); Custom Class: class Custom_Validators_CheckPhoneNumber extends Zend_Validate_Abstract{ const IN_USE = 'inUse'; protected $_messageTemplates = array( self::IN_USE => "'%value%' is currently in use" ); public function isValid($value) { $this->_setValue($value); $user_check = Users::getActive(preg_replace("/[^0-9]/", "", $value)); if($user_check->id){ $this->_error(self::IN_USE); return false; } return true; } } Just fails does not give the "IN_USE" error.

    Read the article

1