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; }
public static function getStatusLabels() { return ArrayHelper::merge(parent::getStatusLabels(), [self::STATUS_CREATED => '已创建', self::STATUS_PAID => '已支付', self::STATUS_DELIVERY => '已发货', self::STATUS_SUCCESS => '已完成', self::STATUS_SUCCESS => '已退款']); }
/** * @inheritdoc */ public function behaviors() { $behaviors = parent::behaviors(); $behaviors['ts'] = ['class' => TimestampBehavior::className(), 'createdAtAttribute' => 'created_at', 'updatedAtAttribute' => 'updated_at']; return $behaviors; }
/** * @inheritdoc */ public function attributeLabels() { return parent::attributeLabels(); }
public function beforeSave($insert) { if (parent::beforeSave($insert)) { $this->level = static::calculateLevel($this); return true; } else { return false; } }
/** * 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); }
?> <?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']]]); }
/** * 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); }
public function setAttribute($name, $value) { if ($this->owner->hasAttribute($name)) { $this->owner->setAttribute($name, $value); } }
/** * 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); }