public function store() { $validator = Validator::make($data = Input::all(), Wards::$rules); if ($validator->fails()) { return Redirect::back()->withErrors($validator)->withInput(); } $ward = new Wards(); $ward->ward_name = Input::get('wardname'); $ward->save(); $ward->ward_type = Input::get('wardtype'); $ward->save(); return Redirect::route('wards.index'); }
public function actionCreate() { $model = new Wards(); $flag = 0; if (!empty($_POST['Wards'])) { $model->attributes = $_POST['Wards']; $model->province_id = $_POST['Wards']['province_id']; if ($model->save()) { Yii::app()->user->setFlash('success', translate('Thêm thành công.')); $this->redirect(PIUrl::createUrl('/admin/Wards/')); } } $dataProvinces = Provinces::model()->getData(); $this->render('create', array('model' => $model, 'dataProvinces' => $dataProvinces)); }