[fw-general] Custom Validate Message doesn¹t show up correctly

2007-10-14 Thread Nayana Hettiarachchi
Hi,

I have written a custom validate Class

class StringEqual extends Zend_Validate_Abstract {const NOT_EQUAL =
string;protected $_messageTemplates = array(self::NOT_EQUAL =
'%value%' Missmatched value);public function isValid ($value)
{$this-_setValue($value['password']); if
($value['password'] !== $value['password2']) {
$this-_error(self::NOT_EQUAL);return false;}
return true;} }

The validation works ok, but I never get the right error message, the error
message array always contains

Here is how I am using the above class

$validators = array(username = array(NotEmpty,
Alpha, 'presence' = 'required'),password =
array(NotEmpty, Alpha, presence = 'required', new StringEqual(),
fields = array(password, password2)));
$validator = new Zend_Filter_Input($filters, $validators, $data);
   

When the StringEqual validation class fails in the errors it says Array (
[password] = Array ( [0] = string ) ) I can't seem to get the actual error
message to show up.

Maybe I am not doing something right, any help is greatly appreciated.

Also I am not sure how to set 2 Values in the $_templateMessage

I also tried doing the following and it also didn¹t work,

  $this-_createMessage(self::NOT_EQUAL, $value['password'] .  Not Equal to
 . $value['password2']);
Before the call to _error();



Regards
Nayana

-- 
Nayana Hettiarachchi [EMAIL PROTECTED]

Sent using the Microsoft Entourage 2004 for Mac Test Drive.



[fw-general] Re: Custom Validate Message doesn¹t show up correctly

2007-10-14 Thread Nayana Hettiarachchi
Sorry some how my previous email lost all the newlines in code,


On 10/14/07 7:26 PM, Nayana Hettiarachchi [EMAIL PROTECTED] wrote:

 Hi,
 
 I have written a custom validate Class
 
 class StringEqual extends Zend_Validate_Abstract
 {
 const NOT_EQUAL = string;
 
 protected $_messageTemplates = array(self::NOT_EQUAL = '%value%'
 Missmatched value);
 
 public function isValid ($value)
 {
 $this-_setValue($value['password']);
 
 if ($value['password'] !== $value['password2']) {
 $this-_error(self::NOT_EQUAL);
 return false;
 }
 
 return true;
 } 
 }
 
 The validation works ok, but I never get the right error message, the error
 message array always contains
 
 Here is how I am using the above class
 
 $validators = array(
 username = array(NotEmpty, Alpha, 'presence' =
 'required'), 
 password = array(NotEmpty, Alpha, presence = 'required',
 new StringEqual(), fields = array(password,
 password2))
 );   
 
 $validator = new Zend_Filter_Input($filters, $validators, $data);

 
 When the StringEqual validation class fails in the errors it says Array (
 [password] = Array ( [0] = string ) ) I can't seem to get the actual error
 message to show up.
 
 Maybe I am not doing something right, any help is greatly appreciated.
 
 Also I am not sure how to set 2 Values in the $_templateMessage
 
 I also tried doing the following and it also didn¹t work,
 
   $this-_createMessage(self::NOT_EQUAL, $value['password'] .  Not Equal to 
 . $value['password2']);
 Before the call to _error();
 
 
 
 Regards
 Nayana


-- 
Nayana Hettiarachchi [EMAIL PROTECTED]
Director, Technology
 
GMI Technologic
Direct: +1 206 315 9319
Cell:   +1 206 713 5759
 
Integrated solutions for market research www.gmi-mr.com

Sent using the Microsoft Entourage 2004 for Mac Test Drive.



[fw-general] usage of Zend_Db_Table_Row

2007-07-11 Thread Nayana Hettiarachchi
Hi There,

 

Congratulations on the 1.0.0 release, I am coming getting back to ZF
after 0.7.0 and its great to see very good progress. Excellent work. 

 

I have a small question regarding implementing a Zend_Db_Table_Row
class, the documentation says the following. 

 

9.6.5.1. Defining Custom Logic for Insert, Update, and Delete in
Zend_Db_Table_Row

The Row class calls protected methods _insert(), _update(), and
_delete() before performing the corresponding operations INSERT, UPDATE,
and DELETE. You can add logic to these methods in your custom Row
subclass.

 

I have a custom Zend_Db_Table_Row class that is associated with a
Zend_Db_Table object,

 

When I work directly on the Zend_Db_Table object and call the insert()
method I don't see that the protected _insert method of the row class
being called. I try to trace through the library code and I did not see
anything apparent that would perform this either. However retrieving a
row by calling createRow() method and calling the save() method does
call the _insert() method. 

 

Is this the intended behavior ? if so then the example provided in the
documentation may not be correct, 

 

Example code

 

//

class Account extends Zend_Db_Table_Abstract

{

   protected $_name = 'account';

   protected $_rowClass = 'CustomRow';

}

class CustomRow extends Zend_Db_Table_Row_Abstract

{

   protected function _insert()

   {

  $this-_data['created_by'] = 21;

   }

}

//test cases 

 

//This method works and calls the _insert() and I see the audit column
created_by populated with value 21 in the db

public function testAddAccountWithRow()

{

   $a = new Account(array('db' = $this-__fixture));

   $row = $a-createRow();

   $row-account_name = 'Unit Test Code via createRow';

   $row-save();

}

//this method doesn't work. With or without specifying the rowClass at
object creation

public function testAddAccountDirect()

{

$a = new Account(array('db' = $this-__fixture, 'rowClass' =
'CustomRow'));

$a-insert(

 array('account_name' = 'Inserting Direct')

  );

}



 

I apologize beforehand if I am asking something that has already been
answered, I tried to search across the mailing list and did not see any
relevant hits. 

 

Nayana Hettiarachchi