public function actionCreate() { $this->htmlOption = array('class' => 'icon-head head-products', 'header' => "新建优惠券", 'button' => array(array('class' => 'scalable save', 'id' => 'form-save', 'header' => '保存'))); $model = new discount_entity(); if ($_POST['discount']) { $model->attributes = $_POST['discount']; $model->discount_customer_email = $_POST['discount']['discount_customer_email']; if ($customer = customer_entity::model()->findByAttributes(array('customer_email' => $model->discount_customer_email))) { $model->discount_customer_ID = $customer->customer_ID; } else { $model->discount_customer_ID = 0; } if ($model->save()) { discount_category::AddItem($model->discount_ID, $_POST['discount']['discount_category_ID']); $this->redirect(array('index')); } $tree = $this->constructCategoryTree($_POST['discount']['discount_category_ID']); } if (!isset($tree)) { $tree = $this->constructCategoryTree(); } $this->constructScript('create'); $this->render('create', array('model' => $model, 'tree' => $tree)); }