예제 #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();
 }
 /**
  * Adding unique key generation
  * @inheritdoc
  */
 public function beforeValidate()
 {
     if (empty($this->key)) {
         $this->key = uniqid('template-region-', true);
     }
     return parent::beforeValidate();
 }
예제 #6
0
 /**
  * @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
 /**
  * @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
 public function beforeValidate()
 {
     if ($this->isNewRecord) {
         $this->created_at = time();
     }
     return parent::beforeValidate();
 }
예제 #11
0
 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
 /**
  * @inheritdoc
  */
 public function beforeValidate()
 {
     if (!empty($this->dateString)) {
         $this->date = strtotime($this->dateString . ' 00:00:01');
     }
     return parent::beforeValidate();
 }
예제 #14
0
 /**
  * @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
 /**
  * @inheritdoc
  */
 public function beforeDelete()
 {
     if (parent::beforeValidate()) {
         $this->status = self::STATUS_DELETED;
         $this->save();
     }
     return false;
 }
예제 #18
0
 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
 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
 public function beforeValidate()
 {
     parent::beforeValidate();
     if ($this->isNewRecord) {
         $this->create_time = time();
     }
     return true;
 }
예제 #23
0
 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();
 }
 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
 public function beforeValidate()
 {
     if(preg_match('/\*/',$this->name)) {
         $this->optional=1;
     } else {
         $this->optional=0;
     }
     return parent::beforeValidate();
 }
예제 #27
0
 public function beforeValidate()
 {
     if (parent::beforeValidate()) {
         $this->action_params = json_encode($this->action_params);
         return true;
     } else {
         return false;
     }
 }
 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();
 }