当前位置: 首页>>代码示例>>PHP>>正文


PHP CForm::submitted方法代码示例

本文整理汇总了PHP中CForm::submitted方法的典型用法代码示例。如果您正苦于以下问题:PHP CForm::submitted方法的具体用法?PHP CForm::submitted怎么用?PHP CForm::submitted使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CForm的用法示例。


在下文中一共展示了CForm::submitted方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: actionUser

 /**
  * Displays the authorization assignments for an user.
  */
 public function actionUser()
 {
     // Create the user model and attach the required behavior
     $userClass = $this->module->userClass;
     $model = CActiveRecord::model($userClass)->findByPk($_GET['id']);
     $model->attachBehavior('rights', new RightsUserBehavior());
     $assignedItems = $this->_authorizer->getAuthItems(null, $model->getId(), null, true);
     $assignments = array_keys($assignedItems);
     // Make sure we have items to be selected
     $selectOptions = Rights::getAuthItemSelectOptions(null, $assignments);
     if ($selectOptions !== array()) {
         // Create a from to add a child for the authorization item
         $form = new CForm(array('elements' => array('itemname' => array('label' => false, 'type' => 'dropdownlist', 'items' => $selectOptions)), 'buttons' => array('submit' => array('type' => 'submit', 'label' => Rights::t('core', 'Assign')))), new AssignmentForm());
         // Form is submitted and data is valid, redirect the user
         if ($form->submitted() === true && $form->validate() === true) {
             // Update and redirect
             $this->_authorizer->authManager->assign($form->model->itemname, $model->getId());
             $item = $this->_authorizer->authManager->getAuthItem($form->model->itemname);
             $item = $this->_authorizer->attachAuthItemBehavior($item);
             Yii::app()->user->setFlash($this->module->flashSuccessKey, Rights::t('core', 'Permission :name assigned.', array(':name' => $item->getNameText())));
             $this->redirect(array('assignment/user', 'id' => $model->getId()));
         }
     } else {
         $form = null;
     }
     // Create a data provider for listing the assignments
     $dataProvider = new AuthItemDataProvider('assignments', array('userId' => $model->getId()));
     // Render the view
     $this->render('user', array('model' => $model, 'dataProvider' => $dataProvider, 'form' => $form));
 }
开发者ID:rusli-nasir,项目名称:smsempresayii,代码行数:33,代码来源:AssignmentController.php

示例2: actionTac_vu_khach

 public function actionTac_vu_khach()
 {
     $dangtin = new LoginForm();
     $khachhang = new Khachhang();
     $form = new CForm('application.views.admin.tac_vu_khach.form_tac_vu_khach', $khachhang);
     $khachhang->setScenario('dang_tin_khach');
     if ($form->submitted('dangtinkhach') && $form->validate()) {
         $id = $khachhang->idkhach;
         $arry = explode("_", $id);
         $username = $arry[0];
         if (isset($arry[1])) {
             $id = $arry[1];
             if ($user = Khachhang::model()->TTkhach($id, $username)) {
                 $dangtin->username = $user['ten_dang_nhap'];
                 $dangtin->password = $user['password'];
                 $dangtin->_identity = new UserIdentity($dangtin->username, $dangtin->password);
                 $dangtin->_identity->authenticate();
                 $dangtin->login();
                 $this->redirect(Yii::app()->request->baseUrl . '/dang-tin');
             } else {
                 $this->__message = "Nhập sai id khách hàng!";
             }
         } else {
             $this->__message = "Nhập sai cú pháp!";
         }
     }
     $this->render('tac_vu_khach', array('form' => $form, 'message' => $this->__message));
 }
开发者ID:BanNT,项目名称:xechieuve,代码行数:28,代码来源:Tac_vu_khachController.php

示例3: actionRegisterconstruct

 public function actionRegisterconstruct()
 {
     $model = new RegisterTestForm();
     $form = new CForm("application.views.formconstruct.registerbuilder", $model);
     if ($form->submitted('register') && $form->validate()) {
         print "Зарегистрирован удачно";
     }
     $this->render("registerconstruct", array('form' => $form));
 }
开发者ID:nikaldem,项目名称:blogYii,代码行数:9,代码来源:FormController.php

示例4: actionOrder

 /**
  * Displays the order page
  */
 public function actionOrder()
 {
     $model = new OrderForm();
     $form = new CForm('application.views.site.orderForm', $model);
     if ($form->submitted('order') && $form->validate()) {
         $this->redirect(array('site/index'));
     } else {
         $this->render('order', array('form' => $form));
     }
 }
开发者ID:AlexanderKupriyanov,项目名称:test-yii,代码行数:13,代码来源:SiteController.php

示例5: actionResult

 public function actionResult()
 {
     $model = new SearchForm();
     $form = new CForm('application.views.search.form', $model);
     if ($form->submitted('search') && $form->validate()) {
         $result = $model->searchResult();
         //$this->redirect(array('search/index'));
         $this->render('index', array('form' => $form, 'result' => $result));
     } else {
         $this->render('index', array('form' => $form));
     }
 }
开发者ID:romero1989,项目名称:phpnetmap,代码行数:12,代码来源:SearchController.php

示例6: actionIndex

 /**
  * Action: Index
  *
  * @access public
  * @return void
  */
 public function actionIndex()
 {
     // Only go ahead with the logout if the end-user is logged in, if the end-user is a guest then we can skip
     // the entire logout procedure, and skip to the redirect back home!
     if (!Yii::app()->user->isGuest) {
         // Has the "authUser" persistent state been set, which contains the user's true authenticated ID, and is
         // it different to the user's current ID?
         if (is_int(Yii::app()->user->getState('authUser')) && Yii::app()->user->getState('authUser') != Yii::app()->user->getState('id') && is_object($authUser = User::model()->findByPk(Yii::app()->user->getState('authUser')))) {
             $model = new \application\model\form\Logout();
             $form = new CForm('application.forms.logout', $model);
             if ($form->submitted() && $form->validate()) {
                 // Has the user opted to switch back to their original account?
                 if ($model->switch) {
                     // Create a new user identity instance, but since we aren't going to use any credentials to
                     // authenticate the user, we can just pass in empty strings.
                     $identity = new UserIdentity('', '');
                     // Attempt to load the identitiy of the user defined by the ID in the "authUser" persistent
                     // state.
                     if ($identity->load(Yii::app()->user->getState('authUser')) && Yii::app()->user->login($identity)) {
                         // The original user account was successfully logged in, redirect to the homepage.
                         $this->redirect(Yii::app()->homeUrl);
                     } else {
                         throw new CException(Yii::t('application', 'An error occured whilst attempting to load your original user account. You have been logged out for security reasons.'));
                     }
                 } else {
                     // Log out the current user. Pass bool(false) as an argument to prevent the entire session
                     // from being destroyed, and instead only delete the persistent states that were created
                     // specifically for the user logged in. An example of why this is the behaviour we want is
                     // storing the language selection in a session - if the website visitor selects French as
                     // the language to view the website in (regardless of whether this functionality is actually
                     // implemented), we don't want that session variable destroyed causing the entire website to
                     // switch back to the default language of English just because the user wanted to log out.
                     // Personally I believe that this should be the default behaviour, but it's not.
                     Yii::app()->user->logout(false);
                     $this->redirect(Yii::app()->homeUrl);
                 }
             }
             // Render the logout page, so that the end-user may be presented with a choice instead of
             // automatically logged out (as if the default).
             $this->render('index', array('form' => $form, 'displayName' => $authUser->displayName));
             // End the application here to prevent any redirection.
             Yii::app()->end();
         } else {
             // Log out the current user. Please refer to the lengthy explaination earlier in this method for why
             // we pass bool(false).
             Yii::app()->user->logout(false);
         }
     }
     // We don't want the user to stay on the logout page. Redirect them back to the homepage.
     $this->redirect(Yii::app()->homeUrl);
 }
开发者ID:mynameiszanders,项目名称:yiiskeleton,代码行数:57,代码来源:LogoutController.php

示例7: actionIndex

 public function actionIndex()
 {
     $model = new ConfigForm();
     $form = new CForm('application.views.config.form', $model);
     $model->load();
     if ($form->submitted('submit')) {
         $model->attributes = $_POST['ConfigForm'];
         if ($model->save()) {
             Yii::app()->user->setFlash('config', Yii::t('app', 'Your new options have been saved.'));
         }
         $this->render('index', array('form' => $form, 'model' => $model, 'result' => $result));
     } else {
         $this->render('index', array('form' => $form));
     }
 }
开发者ID:romero1989,项目名称:phpnetmap,代码行数:15,代码来源:ConfigController.php

示例8: actionUpdate

 /**
  * @param $id
  * @throws CHttpException
  */
 public function actionUpdate($id)
 {
     $model = $this->loadModel($id);
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     $formElements = ['title' => 'Update ' . $model->sectionName . ' description', 'elements' => ['<label>Section Name</label><span>' . $model->sectionName . '</span>', 'description' => ['type' => 'textarea']], 'buttons' => ['save' => ['type' => 'submit', 'label' => 'Save']]];
     $form = new CForm($formElements, $model);
     if ($form->submitted('save') && $form->validate()) {
         if ($model->save()) {
             Yii::app()->user->setFlash('success', 'Surveillance section description updated successfully');
             $this->redirect(['index']);
         }
         Yii::app()->user->setFlash('error', 'Surveillance section description not updated successfully,' . ' please contact your administrator');
     }
     $this->render('update', ['model' => $model, 'form' => $form]);
 }
开发者ID:schrapps,项目名称:risksur,代码行数:20,代码来源:AdminsurveillancesectionsController.php

示例9: run

 public function run()
 {
     if (!Yii::app()->user->isGuest) {
         $this->redirect('index.php');
     }
     $form = new CForm('application.views.user.registerForm');
     $form['user']->model = new User('register');
     $form['profile']->model = new UserProfile();
     if ($form->submitted('register') && $form->validate()) {
         $user = $form['user']->model;
         $profile = $form['profile']->model;
         if ($user->save(false)) {
             $profile->id = $user->id;
             $profile->save(false);
             $this->redirect(array('site/index'));
         }
     } else {
         $this->render('register', array('form' => $form));
     }
 }
开发者ID:robebeye,项目名称:MusicDream,代码行数:20,代码来源:RegisterAction.php

示例10: actionDang_tin

 /**
  * Đăng tin rao vặt
  */
 public function actionDang_tin($currentPage = 1)
 {
     if (Yii::app()->user->name == 'Guest' || !isset(Yii::app()->user->userId)) {
         $this->redirect(Yii::app()->homeUrl . 'dang-nhap');
     }
     $form = new CForm('application.views.user.rao_vat._form');
     $form['tinkhachhang']->model = new Tinkhachhang();
     $form['tinraovat']->model = $tinraovat = new Tinraovat();
     $noticeMessage = '';
     if ($form->submitted('dangtin') && $form->validate()) {
         $tinkhachhang = $form['tinkhachhang']->model;
         $tinraovat = $form['tinraovat']->model;
         //Nếu không đủ tiền để đăng tin sẽ không đăng
         if ($tinkhachhang->trutien(Tinraovat::CODE_RV)) {
             $tinkhachhang->ma_loai_tin = Tinraovat::CODE_RV;
             if ($tinkhachhang->save(false)) {
                 $image = CUploadedFile::getInstance($tinraovat, 'anh');
                 if ($image) {
                     $newName = md5(microtime(true) . 'xechieuve') . $image->name;
                     $tinraovat->anh = $newName;
                     $image->saveAs(Tinraovat::IMAGE_DIR_RV . $newName);
                 }
                 $tinraovat->ma_tin = $tinkhachhang->ma_tin;
                 $tinraovat->save(false);
                 $this->__message = "Tin bạn đăng đã được hiển thị tại trang rao vặt";
             }
         } else {
             $this->__message = "Tài khoản của bạn không đủ để đăng tin";
         }
     }
     $tinraovat = new Tinraovat();
     $paginatorRV = new Paginate($currentPage, new Tinkhachhang(), self::LIMITED_REDCORD_RV, ' ma_loai_tin = ' . Tinraovat::CODE_RV);
     $listTinRV = $tinraovat->listTinRV($paginatorRV);
     //render view
     $data = array('form' => $form, 'listTinRV' => $listTinRV, 'paginatorRV' => $paginatorRV, 'urlPaginatorRV' => 'rao_vat/pagedtrv?page=', 'ajaxElementId' => '#tableRV', 'message' => $this->__message);
     if (Yii::app()->request->isAjaxRequest) {
         $this->renderPartial('dang_tin', $data);
     } else {
         $this->render('dang_tin', $data);
     }
 }
开发者ID:BanNT,项目名称:xechieuve,代码行数:44,代码来源:Rao_vatController.php

示例11: actionUpdateEvaContext

 public function actionUpdateEvaContext($id)
 {
     Yii::log("actionUpdateEvaContext called", "trace", self::LOG_CAT);
     $this->setPageTitle('Update Evaluation Context');
     if (isset($_POST['pageId'])) {
         SystemController::savePage($this->createUrl('updateEvaContext', ['id' => $id]));
     }
     $evaluationHeader = EvaluationHeader::model()->with('evalDetails')->find('t.evalId=:evaId', [':evaId' => $id]);
     //$this->frameworkId = Yii::app()->session['surDesign']['id'];
     $dataArray = [];
     $dataArray['formType'] = 'Update';
     $model = new EvalForm();
     //print_r(FrameworkContext::model()->getFrameworkSummary($this->frameworkId)); die;
     $returnArray = self::getElementsAndDynamicAttributes();
     $elements = $returnArray['elements'];
     $model->setRules($returnArray['rules']);
     $model->setProperties($returnArray['dynamicDataAttributes']);
     $model->setAttributeLabels($returnArray['labels']);
     //print_r($model->attributes); die;
     foreach ($model->attributes as $attributeName => $attributeVal) {
         $attributeNameAndId = explode('_', $attributeName);
         foreach ($evaluationHeader->evalDetails as $evaluationData) {
             if (isset($attributeNameAndId[1]) && $attributeNameAndId[1] == $evaluationData->evalElementsId) {
                 $model->setPropertyName($attributeName, $evaluationData->value);
                 if (DForm::isJson($evaluationData->value)) {
                     $model->setPropertyName($attributeName, json_decode($evaluationData->value));
                 }
                 break;
             }
         }
     }
     $elements['buttons'] = ['updateEvaluation' => ['label' => 'Update evaluation context', 'type' => 'submit']];
     // generate the elements form
     $form = new CForm($elements);
     $form['evaluationHeader']->model = $evaluationHeader;
     $form['evaContext']->model = $model;
     if ($form->submitted('updateEvaluation')) {
         //die('opop');
         $evaluationHeader = $form['evaluationHeader']->model;
         $evaluationHeader->frameworkId = Yii::app()->session['surDesign']['id'];
         $evaluationHeader->userId = Yii::app()->user->id;
         $model->setProperties($_POST['EvalForm']);
         //var_dump($model); die;
         //save the componentHead values
         if ($evaluationHeader->save() && $model->save($evaluationHeader->evalId, false)) {
             //
             if (isset(Yii::app()->session['evaContext'])) {
                 Yii::app()->session->add('evaContext', ['id' => $evaluationHeader->evalId, 'name' => $evaluationHeader->evaluationName, 'questionId' => $evaluationHeader->questionId]);
             }
             Yii::app()->user->setFlash('success', Yii::t("translation", "Evaluation protocol updated successfully"));
             $this->redirect(['listEvaContext']);
             return;
         }
         Yii::app()->user->setFlash('error', Yii::t("translation", "An error occurred when updating the " . "evaluation context, please try again or contact your administrator if the problem persists"));
     }
     $this->docName = 'addEvaContext';
     $page = SystemController::getPageContent($this->docName);
     $this->render('context', ['model' => $model, 'dataArray' => $dataArray, 'form' => $form, 'page' => $page]);
 }
开发者ID:schrapps,项目名称:risksur,代码行数:59,代码来源:EvaluationController.php

示例12: actionForm

 public function actionForm()
 {
     $this->cekLogin('form');
     if ($this->isWizard) {
         $this->backAction = 'division';
     }
     $model = new RegistrationForm();
     $model->initComponent($this->rec->id, O::app()->user->id);
     $form = new CForm(array('elements' => $model->elements, 'buttons' => array('submit-form' => array('type' => 'submit', 'label' => O::t('oprecx', 'Save'))), 'activeForm' => array('class' => 'CActiveForm'), 'attributes' => array('id' => 'reg-form')), $model);
     if ($form->submitted('save') && $form->validate() && $model->save()) {
         //if ($this->isWizard) $this->redirect($this->getURL('interview', array('wiz' => 1)));
         if ($this->afterSave('interview')) {
             return;
         }
     }
     $this->render('form', array('form' => $form));
 }
开发者ID:eneelkant,项目名称:oprecx-project,代码行数:17,代码来源:DefaultController.php

示例13: actionUpload

 public function actionUpload()
 {
     $model = new BackupUpload();
     $form = new CForm('application.models.uploadForm', $model);
     if ($form->submitted('submit') && $form->validate()) {
         $form->model->backup = CUploadedFile::getInstance($form->model, 'backup');
         $fc = file_get_contents($form->model->backup->tempName);
         $xml = new SimpleXMLElement($fc, LIBXML_NOCDATA);
         foreach ($xml->record as $record) {
             foreach ((array) $record->attributes() as $val) {
                 if (AbuserTrigger::model()->findByAttributes($val) === null) {
                     $tr = new AbuserTrigger();
                     $tr->attributes = $val;
                     if ($tr->validate()) {
                         $tr->save();
                     }
                 }
             }
         }
         Yii::app()->user->setFlash('success', 'File Uploaded');
         $this->redirect(array('upload'));
     }
     $this->render('upload', array('form' => $form));
 }
开发者ID:richardsonlima,项目名称:echofish,代码行数:24,代码来源:TriggerController.php

示例14: actionUpdate

 /**
  * Updates an authorization item.
  */
 public function actionUpdate()
 {
     // Get the authorization item
     $model = $this->loadModel();
     // Create the authorization item form
     $form = new CForm('rights.views.authItem.authItemForm', new AuthItemForm('update'));
     // Form is submitted and data is valid
     if ($form->submitted() === true && $form->validate() === true) {
         // Update the item and load it
         $this->_authorizer->updateAuthItem($_GET['name'], $form->model->name, $form->model->description, $form->model->bizRule, $form->model->data);
         $item = $this->_authorizer->authManager->getAuthItem($form->model->name);
         $item = $this->_authorizer->attachAuthItemBehavior($item);
         // Set a flash message for updating the item
         Yii::app()->user->setFlash($this->module->flashSuccessKey, Rights::t('core', ':name updated.', array(':name' => $item->getNameText())));
         // Redirect to the correct destination
         $this->redirect(array(isset($_GET['redirect']) === true ? urldecode($_GET['redirect']) : 'authItem/permissions'));
     }
     // Create a form to add children to the authorization item
     $type = Rights::getValidChildTypes($model->type);
     $exclude = array($this->module->superuserName);
     $selectOptions = Rights::getParentAuthItemSelectOptions($model, $type, $exclude);
     if ($selectOptions !== array()) {
         // Create the child form
         $childForm = new CForm(array('elements' => array('name' => array('label' => false, 'type' => 'dropdownlist', 'items' => $selectOptions)), 'buttons' => array('submit' => array('type' => 'submit', 'label' => Rights::t('core', 'Add')))), new AuthChildForm());
         // Child form is submitted and data is valid
         if ($childForm->submitted() === true && $childForm->validate() === true) {
             // Add the child and load it
             $this->_authorizer->authManager->addItemChild($_GET['name'], $childForm->model->name);
             $child = $this->_authorizer->authManager->getAuthItem($childForm->model->name);
             $child = $this->_authorizer->attachAuthItemBehavior($child);
             // Set a flash message for adding the child
             Yii::app()->user->setFlash($this->module->flashSuccessKey, Rights::t('core', 'Child :name added.', array(':name' => $child->getNameText())));
             // Reidrect to the same page
             $this->redirect(array('authItem/update', 'name' => $_GET['name']));
         }
     } else {
         $childForm = null;
     }
     // Set the values for the form fields
     $form->model->name = $model->name;
     $form->model->description = $model->description;
     $form->model->type = $model->type;
     $form->model->bizRule = $model->bizRule !== 'NULL' ? $model->bizRule : '';
     $form->model->data = $model->data !== null ? serialize($model->data) : '';
     $parentDataProvider = new AuthItemParentDataProvider($model);
     $childDataProvider = new AuthItemChildDataProvider($model);
     // Render the view
     $this->render('update', array('model' => $model, 'parentDataProvider' => $parentDataProvider, 'childDataProvider' => $childDataProvider, 'form' => $form, 'childForm' => $childForm));
 }
开发者ID:rusli-nasir,项目名称:smsempresayii,代码行数:52,代码来源:AuthItemController.php

示例15: actionChinh_sua_thong_tin

 public function actionChinh_sua_thong_tin()
 {
     $this->_checkLogin();
     $form = new CForm('application.views.user.khach_hang._formChinhsuathongtin');
     $khachHang = $form->model = Khachhang::model()->findByPk(Yii::app()->user->userId);
     $pass = $khachHang->password;
     $khachHang->password = "";
     $khachHang->setScenario('update');
     $array = array(Yii::app()->user->name, Yii::app()->user->userId);
     $id = implode("_", $array);
     $khachHang->id = $id;
     $anh = $khachHang->anh_dai_dien;
     if ($form->submitted('chinhsua') && $form->validate()) {
         $image = CUploadedFile::getInstance($khachHang, 'anh_dai_dien');
         if ($image) {
             //Nếu tồn tại ảnh trong CSDL thì sẽ xóa ảnh cũ trong thư mục ảnh
             if ($anh) {
                 unlink(Yii::app()->basePath . '/../' . Khachhang::AVARTAR_DIR . $anh);
             }
             $newName = md5(microtime(true) . 'xechieuve') . $image->name;
             $khachHang->anh_dai_dien = $newName;
             $image->saveAs(Khachhang::AVARTAR_DIR . $newName);
         } else {
             $khachHang->anh_dai_dien = $anh;
         }
         if (md5($khachHang->password) == $pass) {
             $khachHang->password = md5($khachHang->password);
             $khachHang->save(FALSE);
             $this->__message = "Sửa thông tin thành công!";
         } else {
             $this->__message = "Thất bại,bạn nhập sai mật khẩu bạn cần nhập chính xác mật khẩu hiện tại của bạn!";
         }
     }
     $form2 = new CForm('application.views.user.khach_hang._formcapnhatpass');
     $khachHang2 = $form2->model = Khachhang::model()->findByPk(Yii::app()->user->userId);
     $khachHang2->setScenario('updatepass');
     if ($form2->submitted('doimatkhau') && $form2->validate()) {
         Khachhang::updatepassword(md5($khachHang2["newPassword"]));
         $this->__message = "Sửa thông tin thành công!";
     }
     $this->render('chinh_sua_thong_tin', array('form' => $form, 'anh' => $anh, 'form2' => $form2, 'message' => $this->__message));
 }
开发者ID:BanNT,项目名称:xechieuve,代码行数:42,代码来源:Khach_hangController.php


注:本文中的CForm::submitted方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。