本文整理汇总了PHP中CFormModel::beforeValidate方法的典型用法代码示例。如果您正苦于以下问题:PHP CFormModel::beforeValidate方法的具体用法?PHP CFormModel::beforeValidate怎么用?PHP CFormModel::beforeValidate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CFormModel
的用法示例。
在下文中一共展示了CFormModel::beforeValidate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: beforeValidate
public function beforeValidate()
{
if (parent::beforeValidate()) {
$cams = array_map('trim', explode(',', $this->hcams));
$c = count($cams);
foreach ($cams as $cam) {
$this->camBuff[] = Cams::model()->findByPK(Cams::model()->getRealId($cam));
}
$this->camBuff = array_filter($this->camBuff);
if (empty($this->camBuff) || count($this->camBuff) != $c) {
$this->addError('cams', $c > 1 ? Yii::t('errors', 'One of cam is wrong') : Yii::t('errors', 'There is no such cam'));
return false;
}
if (!is_array($this->emails)) {
$emails = array_map('trim', explode(',', $this->emails));
} else {
$emails = array_map('trim', $this->emails);
}
$c = count($emails);
$this->emailBuff = Users::model()->findAllByAttributes(array('email' => $emails));
if (empty($this->emailBuff) || count($this->emailBuff) != $c) {
$this->addError('emails', $c > 1 ? Yii::t('errors', 'One of user is wrong') : Yii::t('errors', 'There is no such user'));
return false;
}
return true;
}
return false;
}
示例2: beforeValidate
public function beforeValidate()
{
$this->db = Yii::app()->db;
// Категория
$category_id = $this->db->createCommand('
SELECT id
FROM yupe_store_category
WHERE id_1c = ' . $this->category_id)->queryRow();
if (empty($category_id)) {
// категории нет в базе
$this->category_id = '449';
} else {
// категория присутствует в базе, возвращаем ее идентификатор
$this->category_id = $category_id['id'];
}
// Товар
$product = $this->db->createCommand()->select('id, alias')->from('{{store_product}}')->where('id_1c=:id', [':id' => $this->id_1c])->queryRow();
if (empty($product)) {
// товар в базе не существует
# code...
} else {
// товар существует
$this->id = $product['id'];
$this->alias = $product['alias'];
}
// Даты
$this->create_time = date('Y-m-d h:m:s', time());
$this->update_time = date('Y-m-d h:m:s', time());
return parent::beforeValidate();
}
示例3: beforeValidate
protected function beforeValidate()
{
$this->message = strip_tags($this->message);
$this->name = strip_tags($this->name);
$this->telephone = strip_tags($this->telephone);
return parent::beforeValidate();
}
示例4: beforeValidate
public function beforeValidate()
{
if (parent::beforeValidate()) {
return true;
}
return false;
}
示例5: beforeValidate
public function beforeValidate()
{
if (parent::beforeValidate()) {
$this->username = strtolower($this->username);
return true;
}
return false;
}
示例6: beforeValidate
public function beforeValidate()
{
if (empty($this->gender)) {
$this->gender = self::GENDER_FEMALE;
}
$this->notime = !(isset($this->hour) && isset($this->minute) && $this->hour >= 0 && $this->hour <= 23 && $this->minute >= 0 && $this->minute <= 59);
return parent::beforeValidate();
}
示例7: beforeValidate
/**
* Метод выполняется перед валидацией
*
* @return bool
*/
public function beforeValidate()
{
$module = Yii::app()->getModule('user');
if ($module->generateNickName) {
$this->nick_name = 'user' . time();
}
return parent::beforeValidate();
}
示例8: beforeValidate
protected function beforeValidate()
{
$this->show = (int) $this->show;
foreach (array("show_user", "to", "tt") as $k) {
$this->{$k} = trim($this->{$k});
}
$this->to_esc = preg_quote($this->to);
$this->tt_esc = preg_quote($this->tt);
return parent::beforeValidate();
}
示例9: beforeValidate
/**
* Change our filename to match our own naming convention
* @return bool
*/
public function beforeValidate()
{
//(optional) Generate a random name for our file to work on preventing
// malicious users from determining / deleting other users' files
if ($this->secureFileNames) {
$this->filename = sha1(Yii::app()->user->id . microtime() . $this->name);
$this->filename .= "." . $this->file->getExtensionName();
}
return parent::beforeValidate();
}
示例10: beforeValidate
/**
* @return bool
*/
public function beforeValidate()
{
/** @var AccountModule $account */
$account = Yii::app()->getModule('account');
if ($account->reCaptcha) {
Yii::import('account.components.AccountReCaptchaValidator');
$validator = new AccountReCaptchaValidator();
$validator->attributes = array('captcha');
$validator->validate($this);
if ($this->hasErrors('captcha')) {
return false;
}
}
return parent::beforeValidate();
}
示例11: beforeValidate
public function beforeValidate()
{
parent::beforeValidate();
return true;
}
示例12: beforeValidate
public function beforeValidate()
{
parent::beforeValidate();
$this->todayCount = $this->todaySended;
if (Yii::app()->user->email) {
$this->email = Yii::app()->user->email;
}
return true;
}
示例13: beforeValidate
public function beforeValidate()
{
$this->validateSubForm();
return parent::beforeValidate();
}
示例14: beforeValidate
protected function beforeValidate()
{
$this->value = trim($this->value);
$exists = false;
foreach ($this->getVisibleSearchParameters() as $searchParam) {
if ($searchParam->parameter->getIdParameter() == $this->parameter) {
$exists = true;
break;
}
}
if (!$exists) {
return false;
}
if ($objParameter = $this->getSearchObjectParamter()) {
if ($objParameter->getType() == DataType::TIMESTAMP && !$this->parseTimestamp()) {
return false;
}
}
return parent::beforeValidate();
}
示例15: beforeValidate
/**
* Loads the user model
* @return boolean whether validation should continue
*/
protected function beforeValidate()
{
$this->_user = User::model()->findCurrent();
return parent::beforeValidate();
}