public function createAction() { $model = new Profile(); if (isset($_POST['model'])) { if ($_POST['model'] == 'profile') { // Uncomment the following line if AJAX validation is needed $this->performAjaxValidation($model); if (isset($_POST['ajax'])) { $model->fillFromArray($_POST); $model->user_id_created = $this->user->user_id; $model->user_id_updated = $this->user->user_id; $model->updated = 'NOW():sql'; $model->created = 'NOW():sql'; $model->model_uset_id = $this->user->user_id; if ($model->save()) { $link = AF::link(array('profiles' => 'update'), array('id' => $model->PkValue)); Message::echoJson('success', array('redirect' => $link)); } else { Message::echoJsonError(__('profile_not_created')); } die; } $model->save(); $this->redirect(); die; } } $gateway = new Gateway(); $gateways = $gateway->getGateways(); Assets::js('jquery.form'); Assets::js('ckeditor/ckeditor'); Assets::js('ckeditor/adapters/jquery'); $this->addToPageTitle('Create Profile'); $this->render('create', array('model' => $model, 'gateways' => $gateways)); }
public function createAction() { if (isset($_POST['ajax']) && isset($_POST['getgateways'])) { $gatewayModel = new Gateway(); $gateways = $gatewayModel->getGateways(); AF::setJsonHeaders('json'); Message::echoJsonSuccess(array('message' => $gateways)); } $model = new CampaignGateway(); $this->performAjaxValidation($model); if (isset($_POST['model']) && $_POST['model'] == 'Campgate') { $model->fillFromArray($_POST); if (isset($_POST['ajax'])) { if ($model->addGatewayById()) { $link = AF::link(array('campgate' => 'view'), array('campaign_id' => $model->campaign_id)); Message::echoJson('success', array('redirect' => $link)); } else { Message::echoJsonError(__('campgate_not_created') . ' ' . $model->errors2string); } die; } $model->addGatewayById(); $this->redirect(); } $this->addToPageTitle('Create Campaign Gateway'); $this->render('create', array('model' => $model)); }