本文整理汇总了PHP中ActiveRecord::beforeValidate方法的典型用法代码示例。如果您正苦于以下问题:PHP ActiveRecord::beforeValidate方法的具体用法?PHP ActiveRecord::beforeValidate怎么用?PHP ActiveRecord::beforeValidate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ActiveRecord
的用法示例。
在下文中一共展示了ActiveRecord::beforeValidate方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: beforeValidate
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();
}
示例2: 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();
}
示例3: 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();
}
示例4: beforeValidate
protected function beforeValidate()
{
$this->handleDate();
return parent::beforeValidate();
}
示例5: beforeValidate
public function beforeValidate()
{
// For configurable product set 0 price
if ($this->use_configurations) {
$this->price = 0;
}
return parent::beforeValidate();
}
示例6: beforeValidate
public function beforeValidate()
{
$this->userId = Yii::app()->user->id;
return parent::beforeValidate();
}
示例7: 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();
}
示例8: 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();
}
示例9: 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();
}
示例10: 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;
}