Пример #1
0
 public function fields()
 {
     $fields = parent::fields();
     unset($fields['createdAt'], $fields['updatedAt']);
     $fields['date'] = function () {
         return $this->createdAt;
     };
     $fields['data'] = function () {
         return Json::decode($this->data);
     };
     return $fields;
 }
Пример #2
0
 public static function getStatusLabels()
 {
     return ArrayHelper::merge(parent::getStatusLabels(), [self::STATUS_CREATED => '已创建', self::STATUS_PAID => '已支付', self::STATUS_DELIVERY => '已发货', self::STATUS_SUCCESS => '已完成', self::STATUS_SUCCESS => '已退款']);
 }
Пример #3
0
 /**
  * @inheritdoc
  */
 public function behaviors()
 {
     $behaviors = parent::behaviors();
     $behaviors['ts'] = ['class' => TimestampBehavior::className(), 'createdAtAttribute' => 'created_at', 'updatedAtAttribute' => 'updated_at'];
     return $behaviors;
 }
Пример #4
0
 /**
  * @inheritdoc
  */
 public function attributeLabels()
 {
     return parent::attributeLabels();
 }
Пример #5
0
 public function beforeSave($insert)
 {
     if (parent::beforeSave($insert)) {
         $this->level = static::calculateLevel($this);
         return true;
     } else {
         return false;
     }
 }
Пример #6
0
 /**
  * Typecast Behavior
  *
  * @access public
  * @return array
  */
 public function behaviors()
 {
     $behaviours = ['timestampBehavior' => ['class' => TimestampBehavior::className(), 'createdAtAttribute' => 'createdTime', 'updatedAtAttribute' => 'updatedTime'], 'typecastBehavior' => ['class' => TypecastBehavior::className(), 'intFields' => ['id', 'memberId', 'snippetId', 'createdTime', 'updatedTime']]];
     return array_merge(parent::behaviors(), $behaviours);
 }
Пример #7
0
?>

    <?php 
echo $form->field($model, 'name')->textInput(['maxlength' => true]);
?>

    <?php 
echo $form->field($model, 'type')->dropDownList(ProductAttribute::getTypeLabels());
?>

    <?php 
echo $form->field($model, 'option')->textInput(['maxlength' => true]);
?>

    <?php 
echo $form->field($model, 'status')->dropDownList(ActiveRecord::getStatusLabels());
?>
    
    <div class="form-group">
        <div class="col-sm-offset-3 col-sm-6">
            <?php 
echo Html::submitButton($model->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-block btn-success' : 'btn btn-block btn-primary']);
?>
        </div>
    </div>

    <?php 
ActiveForm::end();
?>

</div>
 public function behaviors()
 {
     return ArrayHelper::merge(parent::behaviors(), [TimestampBehavior::className(), 'trim' => ['class' => TrimBehavior::className(), 'attributes' => ['attribute_option']]]);
 }
Пример #9
0
 /**
  * Typecast Behavior
  *
  * @access public
  * @return array
  */
 public function behaviors()
 {
     $behaviours = ['timestampBehavior' => ['class' => TimestampBehavior::className(), 'createdAtAttribute' => 'createdTime', 'updatedAtAttribute' => 'updatedTime'], 'typecastBehavior' => ['class' => TypecastBehavior::className(), 'intFields' => ['id', 'lastSeenTime', 'createdTime', 'updatedTime'], 'boolFields' => ['isActive', 'isAdmin']]];
     return array_merge(parent::behaviors(), $behaviours);
 }
Пример #10
0
 public function setAttribute($name, $value)
 {
     if ($this->owner->hasAttribute($name)) {
         $this->owner->setAttribute($name, $value);
     }
 }
Пример #11
0
 /**
  * Typecast Behavior
  *
  * @access public
  * @return array
  */
 public function behaviors()
 {
     $behaviours = ['timestampBehavior' => ['class' => TimestampBehavior::className(), 'createdAtAttribute' => 'createdTime', 'updatedAtAttribute' => 'updatedTime'], 'typecastBehavior' => ['class' => TypecastBehavior::className(), 'intFields' => ['id', 'languageId', 'memberId', 'views', 'downloads', 'createdTime', 'updatedTime'], 'boolFields' => ['isHidden']]];
     return array_merge(parent::behaviors(), $behaviours);
 }