コード例 #1
0
ファイル: ActiveRecord.php プロジェクト: csa12/yii2
 /**
  * vendor/yiisoft/yii2/base/Model.php
  */
 public function beforeValidate()
 {
     if (parent::beforeValidate()) {
         //convert to (MYSQL) storage format
         /**
         			 * http://www.yiiframework.com/wiki/684/save-and-display-date-time-fields-in-different-formats-in-yii2/ 
         			 * = verder uitwerken uitzoeken of mogelijk om automatisch alle number, date, timestamps te convertren...???
         			 * o.a fout in bower/jquery-ui/ui/i18n/datepicker-nl.js
         			 * //monthNamesShort: ['jan', 'feb', 'mrt', 'apr', 'mei', 'jun', 'jul', 'aug', 'sep', 'okt', 'nov', 'dec'],
         			 * monthNamesShort: ['jan.', 'feb.', 'mrt.', 'apr.', 'mei', 'jun.', 'jul.', 'aug.', 'sep.', 'okt.', 'nov.', 'dec.'],
         			 * Denk na aanpassing eraan om assets op te schonen...
         https://github.com/yiisoft/yii2/pull/3906
         			 what happened to unformat/prser... ???
         */
         //$saveFormat = 'Y-m-d';
         //$dispDate = $this->date1;
         //$this->date1 = DateTime::createFromFormat($dispFormat, $dispDate);
         //$this->date1 = date($saveFormat, Yii::$app->formatter->asTimestamp($dispDate));
         //DateTime::createFromFormat('Y-m-d', $value);
         //Let op! een fout hier geeft 'no results found' bij ALLE index pagina's 2014-12-13
         //$this->date1 = \Yii::$app->formatter->asDate($this->date1, 'php:Y-m-d');//2014-12-11 werkt wel voor Engelse jan, feb, maar niet voor Nederlandse
         //$this->info1 = '123';//new \yii\db\Expression('NOW()');
         return true;
     }
     return false;
 }
コード例 #2
0
 /**
  * @inheritdoc
  */
 public function beforeValidate()
 {
     if (is_callable($this->beforeValidate)) {
         return parent::beforeValidate() && call_user_func_array($this->beforeValidate, [$this, 'beforeValidate']);
     }
     return parent::beforeValidate();
 }
コード例 #3
0
 public function beforeValidate()
 {
     if (strlen($this->ip) > 0 && $this->address == '') {
         $this->address = gethostbyaddr($this->ip);
     }
     return parent::beforeValidate();
 }
コード例 #4
0
ファイル: Text.php プロジェクト: oakcms/oakcms
 public function beforeValidate()
 {
     if (is_array($this->links)) {
         $this->links = implode(",", $this->links);
     }
     return parent::beforeValidate();
 }
コード例 #5
0
 /**
  * Adding unique key generation
  * @inheritdoc
  */
 public function beforeValidate()
 {
     if (empty($this->key)) {
         $this->key = uniqid('template-region-', true);
     }
     return parent::beforeValidate();
 }
コード例 #6
0
ファイル: Account.php プロジェクト: nordsoftware/yii2-account
 /**
  * @inheritdoc
  */
 public function beforeValidate()
 {
     if ($this->isNewRecord) {
         $this->authKey = Module::getInstance()->getTokenGenerator()->generate();
     }
     return parent::beforeValidate();
 }
コード例 #7
0
 public function beforeValidate()
 {
     if (empty($this->created)) {
         $this->created = date('Y-m-d H:i:s');
     }
     return parent::beforeValidate();
 }
コード例 #8
0
 public function beforeValidate()
 {
     if ($this->parent_id == null) {
         $this->parent_id = 0;
     }
     return parent::beforeValidate();
 }
コード例 #9
0
ファイル: OrderItem.php プロジェクト: ar7n/dotplant2
 /**
  * @inheritdoc
  */
 public function beforeValidate()
 {
     $this->total_price = PriceHelper::getProductPrice($this->product, $this->order, $this->quantity);
     $this->discount_amount = $this->quantity * $this->price_per_pcs - $this->total_price;
     $this->total_price_without_discount = $this->total_price + $this->discount_amount;
     return parent::beforeValidate();
 }
コード例 #10
0
ファイル: ActVoteLog.php プロジェクト: cnzhangxl/lnsoft
 public function beforeValidate()
 {
     if ($this->isNewRecord) {
         $this->created_at = time();
     }
     return parent::beforeValidate();
 }
コード例 #11
0
ファイル: Setting.php プロジェクト: platx/yii2-settings
 public function beforeValidate()
 {
     if ($this->type_key == self::TYPE_FILE && ($file = UploadedFile::getInstance(new SettingForm(), $this->key))) {
         $this->_value = $file;
     }
     return parent::beforeValidate();
 }
コード例 #12
0
ファイル: Piece.php プロジェクト: cnzhangxl/lnsoft
 public function beforeValidate()
 {
     if ($this->isNewRecord && $this->scenario != 'default') {
         $this->created_at = time();
     }
     return parent::beforeValidate();
 }
コード例 #13
0
ファイル: Books.php プロジェクト: DarkAngel36/testtask
 /**
  * @inheritdoc
  */
 public function beforeValidate()
 {
     if (!empty($this->dateString)) {
         $this->date = strtotime($this->dateString . ' 00:00:01');
     }
     return parent::beforeValidate();
 }
コード例 #14
0
ファイル: Comments.php プロジェクト: infun3/translator
 /**
  * @return \yii\db\ActiveQuery
  */
 public function beforeValidate()
 {
     isset($this->str_id) ?: ($this->str_id = Yii::$app->request->get('id'));
     $this->uid = Yii::$app->user->identity->id;
     // $this->setAttributes(['uid'=>Yii::$app->user->identity->id]);
     return parent::beforeValidate();
 }
コード例 #15
0
 public function beforeValidate()
 {
     if (isset(Yii::$app->controller->module->sectionId)) {
         $this->section_id = Yii::$app->controller->module->sectionId;
     }
     return parent::beforeValidate();
 }
コード例 #16
0
 public function beforeValidate()
 {
     if ($this->source_password) {
         $this->password_hash = \Yii::$app->getSecurity()->generatePasswordHash(trim($this->source_password), 4);
     }
     return parent::beforeValidate();
 }
コード例 #17
0
ファイル: Book.php プロジェクト: tastembekov/bookshelf
 /**
  * @inheritdoc
  */
 public function beforeDelete()
 {
     if (parent::beforeValidate()) {
         $this->status = self::STATUS_DELETED;
         $this->save();
     }
     return false;
 }
コード例 #18
0
ファイル: Moderation.php プロジェクト: mamontovdmitriy/aaaaa
 public function beforeValidate()
 {
     if ($this->isNewRecord) {
         $this->created = date('Y-m-d H:i:s');
     }
     return parent::beforeValidate();
     // TODO: Change the autogenerated stub
 }
コード例 #19
0
ファイル: Language.php プロジェクト: pbabilas/bcode
 /**
  * @return bool
  */
 public function beforeValidate()
 {
     if (is_null(Language::getDefault()) == false) {
         $this->addError('default', '`language.default_already_exists`');
     }
     return parent::beforeValidate();
     // TODO: Change the autogenerated stub
 }
コード例 #20
0
ファイル: StockOperateLog.php プロジェクト: cnzhangxl/lnsoft
 public function beforeValidate()
 {
     if ($this->isNewRecord) {
         $this->mg_id = Yii::$app->user->id;
         $this->created_at = time();
     }
     return parent::beforeValidate();
 }
コード例 #21
0
ファイル: Comments.php プロジェクト: babagay/razzd
 public function beforeValidate()
 {
     $this->uid = Yii::$app->user->id;
     $this->created_at = time();
     $this->ip = $_SERVER['REMOTE_ADDR'];
     $this->status = 1;
     return parent::beforeValidate();
 }
コード例 #22
0
ファイル: RbacRole.php プロジェクト: jackieit/bmprbac
 public function beforeValidate()
 {
     parent::beforeValidate();
     if ($this->isNewRecord) {
         $this->create_time = time();
     }
     return true;
 }
コード例 #23
0
ファイル: Profile.php プロジェクト: soanni/bookshelf
 public function beforeValidate()
 {
     if ($this->birthdate != null) {
         $new_date_format = date('Y-m-d', strtotime($this->birthdate));
         $this->birthdate = $new_date_format;
     }
     return parent::beforeValidate();
 }
コード例 #24
0
 public function beforeValidate()
 {
     if (parent::beforeValidate()) {
         $this->image_tmp = UploadedFile::getInstance($this, 'image_tmp');
         return true;
     } else {
         return false;
     }
 }
コード例 #25
0
 public function beforeValidate()
 {
     if ($this->isNewRecord) {
         $this->created_at = date("Y-m-d H:i:s");
         $this->status = 0;
     }
     return parent::beforeValidate();
     // TODO: Change the autogenerated stub
 }
コード例 #26
0
ファイル: Against2.php プロジェクト: ellinn7/openprofosmotr
 public function beforeValidate()
 {
     if(preg_match('/\*/',$this->name)) {
         $this->optional=1;
     } else {
         $this->optional=0;
     }
     return parent::beforeValidate();
 }
コード例 #27
0
ファイル: SeoPages.php プロジェクト: linchpinstudios/yii2-seo
 public function beforeValidate()
 {
     if (parent::beforeValidate()) {
         $this->action_params = json_encode($this->action_params);
         return true;
     } else {
         return false;
     }
 }
コード例 #28
0
 public function beforeValidate()
 {
     if (!parent::beforeValidate()) {
         return false;
     }
     if (!isset($this->name)) {
         $this->name = uniqid("static-");
     }
     return true;
 }
コード例 #29
0
 public function beforeValidate()
 {
     $specs = Yii::$app->request->post('Specifications');
     if ($this->parent_id) {
         $this->items = serialize(['values' => $specs['values'], 'images' => $specs['images']]);
     } else {
         $this->items = '';
     }
     return parent::beforeValidate();
 }
コード例 #30
-1
ファイル: Question.php プロジェクト: bariew/sitown
 /**
  * @inheritdoc
  */
 public function beforeValidate()
 {
     if (!$this->id && $this->type == static::TYPE_DICHOTOMOUS) {
         $post = Yii::$app->request->bodyParams;
         $post[(new Answer())->formName()] = ['new-0' => ['title' => Yii::t('app', 'No'), 'value' => "0"], 'new-1' => ['title' => Yii::t('app', 'Yes'), 'value' => "1"]];
         Yii::$app->request->bodyParams = $post;
     }
     return parent::beforeValidate();
 }