Re: Overriding form helper error messages in CakePHP 2.0

2012-08-10 Thread William Notowidagdo
Hi Richard,

Same here. I'm using 2.2.1. Though the doc said we can do that 
http://book.cakephp.org/2.0/en/core-libraries/helpers/form.html

On Monday, October 24, 2011 9:44:33 PM UTC+7, Richard@Home wrote:

 Hi all. 

 I have the following $validate in my User model: 

 var $validate = array( 
 'email'=array( 
 'required'=array( 
 'rule'='notEmpty', 
 'message'='cannot be blank' 
 ), 
 'email'=array( 
 'rule'='email', 
 'message'='must be a valid email address' 
 ), 
 'unique'=array( 
 'rule'='isUnique', 
 'message'='that email is already in use' 
 ) 
 ), 
 'password'=array( 
 'required'=array( 
 'rule'='notEmpty', 
 'message'='cannot be blank' 
 ), 
 'length'=array( 
 'rule'=array('minLength', 6), 
 'message'='must be at least 6 letters, 
 numbers or symbols' 
 ), 
 'matches'=array( 
 'rule'='passwordsMatch', 
 'message'='passwords do not match' 
 ) 
 ) 
 ); 


 And I'm trying to override the 'unique' email address message in my 
 form with: 

 echo $this-Form-input('User.email', array( 
 'error'=array( 
 'unique' = 'That email is already in use. Have you ' . 
 $this-Html- 
 link('forgotten your password', 
 array('action'='forgotten_password')) . '?' 
 ) 
 )); 



 But it's still displaying the default validate message, not the custom 
 one. 

 What am I doing wrong? 

 Thanks in advance. 


-- 
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en-US.




Re: Model validation on unit testing

2009-07-22 Thread William Notowidagdo
Thanks. I will try it.

On Wed, Jul 22, 2009 at 4:33 PM, Joe joetsu...@gmail.com wrote:

  'between' = array(
  'rule' = array('between', 1, 5),
  'message' = '1 - 5 only'
  ),

 should be (between and range)

  'between' = array(
  'rule' = array('range', 1, 5),
  'message' = '1 - 5 only'
  ),

 for williamn's question,

 put 'required'=true in the validate rule
 other wise, as nth is provided, and nth is required, it just passed!!

 On 7月22日, 下午4時49分, Joe joetsu...@gmail.com wrote:
  model/rating.php
  class Rating extends AppModel {
 
  var $name = 'Rating';
  var $validate = array(
  'score' = array(
  'numeric' = array(
  'rule' = 'numeric',
  'message' = 'numeric score only'
  ),
  'between' = array(
  'rule' = array('between', 1, 5),
  'message' = '1 - 5 only'
  ),
  )
  );}
 
  test/models/rating.test.php:
  function testScoreRange() {
  $this-data = array(
  'score'  = 10,
  'url_id'  = 10,
  );
  $this-Rating-create();
  $this-Rating-set($this-data);
  $result = $this-Rating-save();
 
  $this-assertFalse($result);
 
  }
 
  On 7月22日, 下午1時57分, Joe joetsu...@gmail.com wrote:
 
 
 
   same here
 
   On 7月10日, 下午5時03分, williamn wnotowida...@gmail.com wrote:
 
Hi all,
 
Did this ever happened to anyone here? :)
 
On Jun 7, 8:14 pm, williamn wnotowida...@gmail.com wrote:
 
 Hi all,
 
 I have a simple model like below
 
 class Department extends AppModel {
 
 var $name = 'Department';
 var $validate = array(
 'code' = array('notempty'),
 'name' = array('notempty'),
 'abbreviation' = array('notempty'),
 'phone_num' = array('notempty')
 );
 
 }
 
 and create a simpletestlike this
 
 function testInvalidCreate() {
 $this-Department-create();
 $this-assertFalse($this-Department-save());
 
 }
 
 correct me if I'm wrong, $this-Department-save() should return
 false
 right? but in my case it returning an array.
 
 Any suggestion?
 
 Thanks.
 



-- 
Best Regards,
--William Notowidagdo

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---