Yii Framework Forum: is this bug in custom validation? - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

is this bug in custom validation? Rate Topic: -----

#1 User is offline   marvix 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 127
  • Joined: 02-August 13

Posted 19 October 2016 - 06:39 AM

Hi,

Am running custom validation rule to check a related table value, its works with now issue, but the error msg is not showing, so this bug, or am doing something wrong?


// the rule
[ 
						'customer_id',
						'validateCustomer',
						'skipOnEmpty' => false,
						'skipOnError' => false,
						'message' => 'Customer validation error!' 
				]

/*
	 * Custom validetor for the customer id
	 */
	public function validateCustomer($attribute, $params) {
		$cID = Customer::find ()->where ( [ 
				'id' => $this->customer_id 
		] )->one ();
		if (! $cID) {
			$this->addError ( 'customer_id', 'Customer validation error!' );
			Yii::trace ( "Error: Customer id: " . $this->customer_id, 'Customer Validation' );
		} else {
			Yii::trace ( "Found: Customer id: " . $this->customer_id, 'Customer Validation' );
		}
	}



Also I can get the field value in the function or in the log, however its working!

Thanks,
0

#2 User is offline   jorge sequeira 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 81
  • Joined: 05-February 13
  • Location:PORTUGAL

Posted 12 November 2017 - 05:37 PM

Same problem here. Can't figure it out...
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users