本文整理汇总了PHP中CActiveRecord::beforeValidate方法的典型用法代码示例。如果您正苦于以下问题:PHP CActiveRecord::beforeValidate方法的具体用法?PHP CActiveRecord::beforeValidate怎么用?PHP CActiveRecord::beforeValidate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CActiveRecord
的用法示例。
在下文中一共展示了CActiveRecord::beforeValidate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: beforeValidate
public function beforeValidate()
{
parent::beforeValidate();
$this->usuario_id = Yii::app()->user->id;
$this->data_cadastro = date('dd/mm/yy');
return true;
}
示例2: beforeValidate
public function beforeValidate()
{
if ($this->isNewRecord) {
$this->product_last_update = new CDbExpression('NOW()');
}
return parent::beforeValidate();
}
示例3: beforeValidate
public function beforeValidate()
{
if (Yii::app()->language == 'de') {
$this->price = str_replace(',', '.', $this->price);
}
return parent::beforeValidate();
}
示例4: beforeValidate
protected function beforeValidate()
{
if (parent::beforeValidate()) {
$this->date = time();
}
return true;
}
示例5: beforeValidate
/**
* Prepares create_time, create_user_id, update_time and
* update_user_ id attributes before performing validation.
*/
protected function beforeValidate()
{
if ($this->isNewRecord) {
// set the create date, last updated date
// and the user doing the creating
if ($this->id == null) {
$this->id = $this->createUUID();
}
$this->created_time = $this->updated_time = new CDbExpression('NOW()');
if ($this->created_by == null) {
$this->created_by = Yii::app()->user->id;
}
if ($this->updated_by == null) {
$this->updated_by = Yii::app()->user->id;
}
} else {
//not a new record, so just set the last updated time
//and last updated user id
$this->updated_time = new CDbExpression('NOW()');
//$this->updated_by = Yii::app()->user->id;
if ($this->updated_by == null) {
$this->updated_by = Yii::app()->user->id;
}
}
return parent::beforeValidate();
}
示例6: beforeValidate
/**
* Prepares id, status, date_entered, created_by, date_modified and
* modified_user_id,deleted attributes before performing validation.
*/
protected function beforeValidate()
{
if ($this->isNewRecord) {
// set the create date, last updated date and the user doing the creating
if (create_guid()) {
$this->id = create_guid();
$this->date_entered = date("Y-m-d H:i:s");
if (frontUserId()) {
$this->created_by = frontUserId();
$this->modified_by = frontUserId();
} else {
$this->created_by = $this->id;
$this->modified_by = $this->id;
}
$this->deleted = 0;
//$this->status = 0;
$this->date_modified = date("Y-m-d H:i:s");
}
} else {
//not a new record, so just set the last updated time and last updated user id
$this->date_modified = date("Y-m-d H:i:s");
if (frontUserId()) {
$this->modified_by = frontUserId();
} else {
$this->modified_by = Yii::app()->user->id;
}
}
return parent::beforeValidate();
}
示例7: beforeValidate
public function beforeValidate()
{
if ($this->getScenario() == 'insert') {
$this->sal = uniqid();
}
return parent::beforeValidate();
}
示例8: beforeValidate
public function beforeValidate()
{
if ($this->isNewRecord) {
$this->ordering_date = $this->convertDate($this->ordering_date);
}
return parent::beforeValidate();
}
示例9: beforeValidate
public function beforeValidate()
{
if ($this->isNewRecord) {
$this->ordering = $this->getNextOrdering();
}
return parent::beforeValidate();
}
示例10: beforeValidate
protected function beforeValidate()
{
if (!parent::beforeValidate()) {
return false;
}
if ($this->scenario == "fromAdmin") {
if ($this->teacher_path_file == NULL) {
$this->addError("teacher_avatar", "teacher_avatar is required");
return false;
}
if (!$this->teacher_path_file->checkExt(array('jpg', 'jpeg', 'png', 'JPG', 'JPEG', 'PNG'))) {
return FALSE;
}
$ext = $this->teacher_path_file->getExtension();
$name = StringHelper::unicode_str_filter($this->teacher_path_file->name);
$storeFolder = Yii::getPathOfAlias('webroot') . '/uploads/teacher/';
$targetPath = $storeFolder;
//4
$teacher_ava = Yii::app()->createAbsoluteUrl('uploads') . '/teacher/' . $name;
if ($ext == "gif" || $ext == "jpg" || $ext == "jpeg" || $ext == "pjepg" || $ext == "png" || $ext == "x-png" || $ext == "GIF" || $ext == "JPG" || $ext == "JPEG" || $ext == "PJEPG" || $ext == "PNG" || $ext == "X_PNG") {
$this->teacher_path_file->save($targetPath, $name);
$this->teacher_avatar = $teacher_ava;
}
}
return TRUE;
}
示例11: beforeValidate
public function beforeValidate()
{
if ($this->isNewRecord) {
$this->member_created_date = new CDbExpression("NOW()");
}
return parent::beforeValidate();
}
示例12: beforeValidate
public function beforeValidate()
{
if (!Yii::app()->getModule('messaging')->hasGroup($this->grp)) {
$this->addError('grp', 'You are not part of this group.');
}
return parent::beforeValidate();
}
示例13: beforeValidate
public function beforeValidate()
{
if ($this->isNewRecord && $this->keyword === null) {
$this->keyword = AdminHelper::generateUrlStr($this->alias, $this, 'keyword');
}
return parent::beforeValidate();
}
示例14: beforeValidate
protected function beforeValidate()
{
if (empty($this->user_id)) {
$this->user_id = Yii::app()->user->id;
}
return parent::beforeValidate();
}
示例15: beforeValidate
public function beforeValidate()
{
if ($this->isNewRecord) {
$this->hash = Yii::app()->functions->makeHash(6);
}
return parent::beforeValidate();
}