Zend_validator and custom error message

View: New views
1 Messages — Rating Filter:   Alert me  

Zend_validator and custom error message

by Michel Morelli :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi all, I have this validator (that does not work). I want to create a custom error message (I wan to insert a link HREF):

class My_Validate_NumberInContactList extends Zend_Validate_Abstract
{
    const ABNAS_ERROR = 'addressBookNumberAlreadySave';
   
    protected $_messageVariables = array ('cid' => 0);
   
    protected $_messageTemplates = array(
        self::ABNAS_ERROR => "Number is already in your contact list (cid = %cid%)",
    );
   
    /**
     * Check if username is not use from another user
     *
     * @param string $value
     */
    function isValid($value) {
        $db = Zend_Registry::get('db');
        $row = $db->fetchRow("SELECT id_contact FROM customer_contact WHERE number = '".$value."' and fk_customer = ".Zend_Auth::getInstance()->getIdentity()->id_customer);
        if (isset($row->id_contact)) {
            $this->_messageVariables['cid'] = $row->id_contact;
            $this->_error(self::ABNAS_ERROR);
            return false;
        }
        return true;
    }
}

The error message is
No property exists by the name '2'

where '2' is the content of $row->id_contact;
Any help is appreciated.

M.
-- 
Michel 'ZioBudda' Morelli                       michel@...
Consulenza sistemistica in ambito OpenSource.
Sviluppo applicazioni web dinamiche (LAMP+Ajax)
Telefono: 0200619074
Telefono Cell: +39-3939890025 --  Fax: +39-0291390660

http://www.ziobudda.net                         ICQ: 58351764  
http://www.ziobuddalabs.it                      Skype: zio_budda
http://www.ajaxblog.it        			MSN: michel@...                   
						JABBER: michel@...
LightInTheBox - Buy quality products at wholesale price