/** * Updates an existing Customer model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id * @return mixed */ public function actionUpdate() { /** @var \yincart\customer\models\CustomerInfo $model */ $model = Kiwi::getCustomerInfo()->find()->where(['user_id' => Yii::$app->user->id])->one(); if (!$model) { $model = Kiwi::getCustomerInfo(['user_id' => Yii::$app->user->id]); } if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['index', 'id' => $model->user_id]); } else { return $this->render('update', ['customerInfo' => $model]); } }
<?php use yii\helpers\Html; use yii\helpers\Url; /** @var \yincart\customer\models\CustomerInfo $customer */ $customerInfo = $customer->customerInfo ?: \kiwi\Kiwi::getCustomerInfo(); $this->params['breadcrumbs'] = ['title' => '个人信息']; ?> <h3 style="margin-left:220px"><?php echo Yii::t('app', 'Your profile'); ?> </h3> <table class="table table-bordered personal-info" > <tr> <th class="col-xs-4"><?php echo Html::encode($customer->getAttributeLabel('username')); ?> </th> <td class="col-xs-8"><?php echo Html::encode($customer->username); ?> </td> </tr> <tr> <th class="col-xs-4"><?php echo Html::encode($customer->getAttributeLabel('email')); ?> </th> <td class="col-xs-8"><?php echo Html::encode($customer->email);
?> <div class="customer-form"> <?php $form = ActiveForm::begin(); // print_r($model->getErrors()); $fieldGroups = []; $fields = []; $fields[] = $form->field($model, 'username')->textInput(['maxlength' => 255]); $fields[] = $form->field($model, 'email')->textInput(['maxlength' => 255]); // $fields[] = $form->field($model, 'password')->passwordInput(['maxlength' => 255]); $fields[] = $form->field($model, 'status')->checkbox(); $fieldGroups[] = ['label' => 'User Info', 'content' => implode('', $fields)]; $fields = []; $customerInfo = $model->customerInfo ?: \kiwi\Kiwi::getCustomerInfo(); $fields[] = $form->field($customerInfo, 'nick_name')->textInput(['maxlength' => 255]); $fields[] = $form->field($customerInfo, 'real_name')->textInput(['maxlength' => 255]); $fields[] = $form->field($customerInfo, 'avatars')->textInput(['maxlength' => 255]); $fields[] = $form->field($customerInfo, 'phone')->textInput(['maxlength' => 255]); $fields[] = $form->field($customerInfo, 'qq')->textInput(['maxlength' => 255]); $fields[] = $form->field($customerInfo, 'address')->textInput(['maxlength' => 255]); $fields[] = $form->field($customerInfo, 'sex')->textInput(); $fields[] = $form->field($customerInfo, 'age')->textInput(); // $fields[] = $form->field($customerInfo, 'payment_password')->textInput(['maxlength' => 255]); $fields[] = $form->field($customerInfo, 'id_card_no')->textInput(['maxlength' => 255]); $fields[] = $form->field($customerInfo, 'id_card_front_pic')->widget(InputFile::className(), ['template' => '<div class="input-group">{input}<span class="input-group-btn">{button}</span></div>', 'options' => ['class' => 'form-control'], 'buttonOptions' => ['class' => 'btn btn-default']]); $fields[] = $form->field($customerInfo, 'id_card_back_pic')->widget(InputFile::className(), ['template' => '<div class="input-group">{input}<span class="input-group-btn">{button}</span></div>', 'options' => ['class' => 'form-control'], 'buttonOptions' => ['class' => 'btn btn-default']]); $fieldGroups[] = ['label' => 'Customer Info', 'content' => implode('', $fields)]; $fields = []; $groups = \kiwi\Kiwi::getGroup()->find()->all();