public function beforeValidate() { // Alias if ($this->alias) { $this->alias = makeAlias($this->alias); } else { $this->alias = makeAlias($this->question); } if ($this->isNewRecord) { // Check if we already have an alias with those parameters if (HelpTopic::model()->exists('alias=:alias', array(':alias' => $this->alias))) { $this->addError('alias', at('There is already a help topic with that alias.')); } } else { // Check if we already have an alias with those parameters if (HelpTopic::model()->exists('alias=:alias AND id!=:id', array(':id' => $this->id, ':alias' => $this->alias))) { $this->addError('alias', at('There is already a help topic with that alias.')); } } return parent::beforeValidate(); }
public function beforeValidate() { /* //date_default_timezone_set('America/Caracas'); $this->actualizado_el = date('d/m/Y h:i:s a', time()); if($this->isNewRecord) $this->creado_el = $this->actualizado_el;*/ //$this->usuario = strtolower($this->usuario); //$this->correo = strtolower($this->correo); return parent::beforeValidate(); }
public function beforeValidate() { if (!empty($this->birthdate_day) || !empty($this->birthdate_month) || !empty($this->birthdate_year)) { $this->birthdate = $this->birthdate_year . "-" . $this->birthdate_month . "-" . $this->birthdate_day; } return parent::beforeValidate(); }
protected function beforeValidate() { $this->handleDate(); return parent::beforeValidate(); }
public function beforeValidate() { // For configurable product set 0 price if ($this->use_configurations) { $this->price = 0; } return parent::beforeValidate(); }
public function beforeValidate() { $this->userId = Yii::app()->user->id; return parent::beforeValidate(); }
/** * @return bool */ public function beforeValidate() { // Save phone as imploded string if (!empty($this->phone_numbers)) { $this->phone = implode(',', $this->phone_numbers); } return parent::beforeValidate(); }
protected function beforeValidate() { if ($this->isNewRecord) { $this->create_time = $this->update_time = time(); if (!$this->order_no) { $this->order_no = sprintf('%s-%d-%06d-%05d', date('YmdHis', $this->create_time), $this->type, $this->sub_type_id, mt_rand(10000, 99999)); } } return parent::beforeValidate(); }
public function beforeValidate() { foreach (array('phone', 'fax', 'workPhone') as $attr) { if (is_array($this->{$attr})) { foreach ($this->{$attr} as $k => &$it) { $it = trim($it); if ($k == 3) { $it = '(' . $it . ')'; } } $this->{$attr} = implode(' ', $this->{$attr}); if (strlen($this->{$attr}) < 5) { $this->{$attr} = ''; } } } if ($this->url == 'http://') { $this->url = ''; } if (!$this->confirmCode) { $this->confirmCode = md5($this->email . time() . time()); } if ($this->password) { $this->password = Security::cryptPassword($this->password, '1'); } if ($this->isNewRecord) { $this->created_timestamp = date('Y-m-d H:i:s'); } return parent::beforeValidate(); }
public function beforeValidate() { if (parent::beforeValidate() && $this->isNewRecord) { $user = User::model()->findByPk($this->user_id); $template = MailerTemplate::model()->findByPk($this->template_id); if (!$this->subject) { $this->subject = $template->constructSubject($user); } if (!$this->body) { $this->body = $template->constructBody($user); } if (!$this->email) { $this->email = $user->email; } } return true; }