/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new AddressResult(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['AddressResult'])) { $model->attributes = $_POST['AddressResult']; if ($model->save()) { $this->redirect(array('admin')); } } $this->render('create', array('model' => $model)); }
/** * name: actionAddAddressByAjax * function:add address when buy product var use new address * @author: shuai.du@jago-ag.cn */ public function actionAddAddressByAjax() { $model = new AddressResult(); if (isset($_POST['AddressResult']) && Yii::app()->request->isAjaxRequest) { $model->attributes = $_POST['AddressResult']; $result = array(); if ($model->save()) { echo 'success@'; echo $model->contact_id . '@'; // echo $model->contact_id; // echo '<li>'. CHtml::radioButton('delivery_address',true,array('value' => $model->contact_id,'id' => 'delivery_address'.$model->contact_id)).CHtml::tag('span', array( // 'class' => 'buyer-address shop_selection'), // $model->s->name . ' ' . $model->c->name . ' ' . $model->d->name . ' ' . $model->address . ' (' . $model->contact_name . ' 收) ' . $model->mobile_phone).'</li>'; $this->renderPartial('address', array('model' => $model)); } else { $errors = $model->getErrors(); foreach ($errors as $error) { ?> <li><?php echo $error[0]; ?> </li> <?php } } } }