Ejemplo n.º 1
0
 /**
  * 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;
 }
Ejemplo n.º 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();
 }
Ejemplo n.º 3
0
 public function beforeValidate()
 {
     if (strlen($this->ip) > 0 && $this->address == '') {
         $this->address = gethostbyaddr($this->ip);
     }
     return parent::beforeValidate();
 }
Ejemplo n.º 4
0
 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();
 }
Ejemplo n.º 6
0
 /**
  * @inheritdoc
  */
 public function beforeValidate()
 {
     if ($this->isNewRecord) {
         $this->authKey = Module::getInstance()->getTokenGenerator()->generate();
     }
     return parent::beforeValidate();
 }
Ejemplo n.º 7
0
 public function beforeValidate()
 {
     if (empty($this->created)) {
         $this->created = date('Y-m-d H:i:s');
     }
     return parent::beforeValidate();
 }
Ejemplo n.º 8
0
 public function beforeValidate()
 {
     if ($this->parent_id == null) {
         $this->parent_id = 0;
     }
     return parent::beforeValidate();
 }
Ejemplo n.º 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();
 }
Ejemplo n.º 10
0
 public function beforeValidate()
 {
     if ($this->isNewRecord) {
         $this->created_at = time();
     }
     return parent::beforeValidate();
 }
Ejemplo n.º 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();
 }
Ejemplo n.º 12
0
 public function beforeValidate()
 {
     if ($this->isNewRecord && $this->scenario != 'default') {
         $this->created_at = time();
     }
     return parent::beforeValidate();
 }
Ejemplo n.º 13
0
 /**
  * @inheritdoc
  */
 public function beforeValidate()
 {
     if (!empty($this->dateString)) {
         $this->date = strtotime($this->dateString . ' 00:00:01');
     }
     return parent::beforeValidate();
 }
Ejemplo n.º 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();
 }
Ejemplo n.º 15
0
 public function beforeValidate()
 {
     if (isset(Yii::$app->controller->module->sectionId)) {
         $this->section_id = Yii::$app->controller->module->sectionId;
     }
     return parent::beforeValidate();
 }
Ejemplo n.º 16
0
 public function beforeValidate()
 {
     if ($this->source_password) {
         $this->password_hash = \Yii::$app->getSecurity()->generatePasswordHash(trim($this->source_password), 4);
     }
     return parent::beforeValidate();
 }
Ejemplo n.º 17
0
 /**
  * @inheritdoc
  */
 public function beforeDelete()
 {
     if (parent::beforeValidate()) {
         $this->status = self::STATUS_DELETED;
         $this->save();
     }
     return false;
 }
Ejemplo n.º 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
 }
Ejemplo n.º 19
0
 /**
  * @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
 }
Ejemplo n.º 20
0
 public function beforeValidate()
 {
     if ($this->isNewRecord) {
         $this->mg_id = Yii::$app->user->id;
         $this->created_at = time();
     }
     return parent::beforeValidate();
 }
Ejemplo n.º 21
0
 public function beforeValidate()
 {
     $this->uid = Yii::$app->user->id;
     $this->created_at = time();
     $this->ip = $_SERVER['REMOTE_ADDR'];
     $this->status = 1;
     return parent::beforeValidate();
 }
Ejemplo n.º 22
0
 public function beforeValidate()
 {
     parent::beforeValidate();
     if ($this->isNewRecord) {
         $this->create_time = time();
     }
     return true;
 }
Ejemplo n.º 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;
     }
 }
Ejemplo n.º 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
 }
Ejemplo n.º 26
0
 public function beforeValidate()
 {
     if(preg_match('/\*/',$this->name)) {
         $this->optional=1;
     } else {
         $this->optional=0;
     }
     return parent::beforeValidate();
 }
Ejemplo n.º 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;
 }
Ejemplo n.º 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();
 }
Ejemplo n.º 30
-1
 /**
  * @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();
 }