/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new Product(); $users = User::getNames(); if (isset($_POST['Product'])) { $model->setX2Fields($_POST['Product']); // $model->price = Formatter::parseCurrency($model->price,false); $model->createDate = time(); if (isset($_POST['x2ajax'])) { $ajaxErrors = $this->quickCreate($model); } else { if ($model->save()) { $this->redirect(array('view', 'id' => $model->id)); } } } if (isset($_POST['x2ajax'])) { $this->renderInlineCreateForm($model, isset($ajaxErrors) ? $ajaxErrors : false); } else { $this->render('create', array('model' => $model, 'users' => $users)); } }