/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new X2Leads(); $users = User::getNames(); foreach (Groups::model()->findAll() as $group) { $users[$group->id] = $group->name; } unset($users['admin']); unset($users['']); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['X2Leads'])) { $temp = $model->attributes; $model->setX2Fields($_POST['X2Leads']); 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)); } }