• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP CForm类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: 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


示例2: 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


示例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: registerAssignScript

    /**
     *
     * @param CActiveRecord $model
     * @param int $id
     * @param array $config 
     */
    public function registerAssignScript($model, $id, array $config = array())
    {
        Yii::app()->controller->beginWidget('zii.widgets.jui.CJuiDialog', array('id' => 'assignDriver', "options" => array('title' => 'Assign Driver', 'autoOpen' => false, 'modal' => true, 'buttons' => array('Close' => 'js:function(){$(this).dialog("close")}', 'Assign' => 'js:function(){' . CHtml::ajax(array('url' => $config['ajaxUrl'], 'type' => 'post', 'dataType' => 'json', 'data' => 'js:$("#assignDriver form").serialize()', 'success' => 'function(r){if(r.success){
					$("#assignDriver").dialog("close");
					$.fn.yiiGridView.update("tracking-grid");
				}; 
				if(!r.success){alert("Gagal assign driver")}}')) . ';}'))), true);
        $driverForm = new CForm(array('elements' => array('driver' => array('type' => 'dropdownlist', 'items' => OrderTracking::getDriverList()), 'id' => array('type' => 'hidden'))), $model);
        echo $driverForm->render();
        Yii::app()->controller->endWidget();
        Yii::app()->clientScript->registerScript($id, "jQuery('body').undelegate('.assignDriver_button','click').delegate('.assignDriver_button','click',function(){\ndriverDialog=jQuery('#assignDriver');\ndriverDialog.dialog('open');\njQuery('#assignDriver input#OrderTracking_id').val(\$(this).attr('rel').replace('grid.',''));\n\treturn false;\n});\t");
    }
开发者ID:aantonw,项目名称:dcourier.system,代码行数:18,代码来源:CTrackOrder.php


示例6: 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


示例7: 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


示例8: 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


示例9: 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


示例10: sendOnAfterResultStatusChange

 function sendOnAfterResultStatusChange($WEB_FORM_ID, $RESULT_ID, $NEW_STATUS_ID = false, $CHECK_RIGHTS = 'Y')
 {
     $NEW_STATUS_ID = intval($NEW_STATUS_ID);
     $dbRes = CForm::GetByID($WEB_FORM_ID);
     if (!($arForm = $dbRes->Fetch())) {
         return;
     }
     CTimeZone::Disable();
     $dbRes = CFormResult::GetByID($RESULT_ID);
     CTimeZone::Enable();
     if (!($arResult = $dbRes->Fetch()) || !$arResult['USER_ID']) {
         return;
     }
     $dbRes = CUser::GetByID($arResult['USER_ID']);
     if (!($arUser = $dbRes->Fetch())) {
         return;
     }
     if (!$NEW_STATUS_ID) {
         $NEW_STATUS_ID = CFormStatus::GetDefault($WEB_FORM_ID);
     }
     $dbRes = CFormStatus::GetByID($NEW_STATUS_ID);
     if (!($arStatus = $dbRes->Fetch()) || strlen($arStatus['MAIL_EVENT_TYPE']) <= 0) {
         return;
     }
     $arTemplates = CFormStatus::GetMailTemplateArray($NEW_STATUS_ID);
     if (!is_array($arTemplates) || count($arTemplates) <= 0) {
         return;
     }
     $arEventFields = array("EMAIL_TO" => $arUser['EMAIL'], "RS_FORM_ID" => $arForm["ID"], "RS_FORM_NAME" => $arForm["NAME"], "RS_FORM_VARNAME" => $arForm["SID"], "RS_FORM_SID" => $arForm["SID"], "RS_RESULT_ID" => $arResult["ID"], "RS_DATE_CREATE" => $arResult["DATE_CREATE"], "RS_USER_ID" => $arResult['USER_ID'], "RS_USER_EMAIL" => $arUser['EMAIL'], "RS_USER_NAME" => $arUser["NAME"] . " " . $arUser["LAST_NAME"], "RS_STATUS_ID" => $arStatus["ID"], "RS_STATUS_NAME" => $arStatus["TITLE"]);
     $dbRes = CEventMessage::GetList($by = "id", $order = "asc", array('ID' => implode('|', $arTemplates), "ACTIVE" => "Y", "EVENT_NAME" => $arStatus["MAIL_EVENT_TYPE"]));
     while ($arTemplate = $dbRes->Fetch()) {
         CEvent::Send($arTemplate["EVENT_NAME"], $arTemplate["SITE_ID"], $arEventFields, "Y", $arTemplate["ID"]);
     }
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:34,代码来源:events.php


示例11: __form_CreateForm

function __form_CreateForm($SID, $__current_dir)
{
    // check collisions
    $dbTmpForm = CForm::GetBySID($SID);
    if ($arTmpForm = $dbTmpForm->Fetch()) {
        return false;
    }
    //$dirName = ToLower($SID);
    $formConfigFile = $__current_dir . '/form.php';
    $fieldsConfigFile = $__current_dir . '/fields.php';
    // check config existence
    if (!file_exists($formConfigFile) || !file_exists($fieldsConfigFile)) {
        return false;
    }
    // load form config
    $arForm = array();
    require $formConfigFile;
    // setup form
    if ($FORM_ID = CForm::Set($arForm, false, 'N')) {
        // load fields config
        $arFormFields = array();
        require $fieldsConfigFile;
        // setup form fields
        foreach ($arFormFields as $key => $arField) {
            CFormField::Set($arField, false, 'N');
        }
        $arStatus = array('FORM_ID' => $FORM_ID, 'TITLE' => 'DEFAULT', 'CSORT' => 100, 'ACTIVE' => 'Y', 'DEFAULT_VALUE' => 'Y', 'arPERMISSION_MOVE' => array(0));
        CFormStatus::Set($arStatus, false, 'N');
    }
    return $FORM_ID;
}
开发者ID:Satariall,项目名称:izurit,代码行数:31,代码来源:lib.php


示例12: __construct

 /**
 * Constructor
 */
 public function __construct($content)
 {
     parent::__construct();
     $this->content = $content;
     $save = isset($content['id']) ? 'save' : 'create';
     $this->AddElement(new CFormElementHidden('id', array('value' => $content['id'])))->AddElement(new CFormElementText('title', array('value' => $content['title'])))->AddElement(new CFormElementText('key', array('value' => $content['key'])))->AddElement(new CFormElementTextarea('data', array('label' => 'Content:', 'value' => $content['data'])))->AddElement(new CFormElementText('type', array('value' => $content['type'])))->AddElement(new CFormElementText('filter', array('value' => $content['filter'])))->AddElement(new CFormElementSubmit($save, array('callback' => array($this, 'DoSave'), 'callback-args' => array($content))))->AddElement(new CFormElementSubmit('delete', array('callback' => array($this, 'DoDelete'), 'callback-args' => array($content))));
     $this->SetValidation('title', array('not_empty'))->SetValidation('key', array('not_empty'));
 }
开发者ID:xd3x4L-1,项目名称:page,代码行数:11,代码来源:CFormContent.php


示例13: __construct

 /** Create all form elements and validation rules in the constructor.
  *
  */
 public function __construct()
 {
     parent::__construct();
     $items = array('tomato', 'potato', 'apple', 'pear', 'banana');
     $shoppingcart = array('potato', 'pear');
     $this->AddElement(new CFormElementCheckboxMultiple('items', array('values' => $items, 'checked' => $shoppingcart)));
     $this->AddElement(new CFormElementSubmit('submit', array('callback' => array($this, 'DoSubmit'))));
 }
开发者ID:Kajja,项目名称:phpmvc,代码行数:11,代码来源:test_checkbox_multiple.php


示例14: get_option

	static function get_option($array_title, $selectedvalue = "") {
		   $option = '<option value="">Aucun</option>';
		   foreach($array_title as $key=>$valeur) {
		   		$selected = CForm::get_selected($selectedvalue, $valeur);
		   		$option = $option . "<option value='" . $key . "'" . $selected . ">" . utf8_encode($valeur) . "</option>\n";
		   }
		   return $option;
	}
开发者ID:rakotobe,项目名称:Rakotobe,代码行数:8,代码来源:CFormCsv.php


示例15: get_option

	static function get_option($selectedvalue, $tablename="pays", $colvaluename="id", $colvuename="nom", $where=1) {
		   $option = "";
		   $result = CTable::select($colvaluename . " , " . $colvuename, $tablename, $where, $colvuename); 
		   while($array = mysql_fetch_array($result)) {
		   		$selected = CForm::get_selected($selectedvalue, $array[$colvaluename]);
		   		$option = $option . "<option value='" . $array[$colvaluename] . "'" . $selected . ">" . ucfirst(utf8_encode(substr($array[$colvuename], 0, 25))) . "</option>\n";
		   }
		   return $option;
	}	
开发者ID:rakotobe,项目名称:Rakotobe,代码行数:9,代码来源:CFormPays.php


示例16: get_option

	static function get_option($selectedvalue, $idtype) {
		   $option = "";
		   $type_possible = CTableQuestion::get_enum('type');
		   foreach($type_possible as $valeur) {
		   		$selected = CForm::get_selected($selectedvalue, $valeur);
		   		$option = $option . "<option value='" . $valeur . "'" . $selected . ">" . $valeur . "</option>\n";
		   }
		   return $option;
	}
开发者ID:rakotobe,项目名称:Rakotobe,代码行数:9,代码来源:CFormQuestion.php


示例17: get_option

	static function get_option($selectedvalue, $tablename, $colvaluename="id", $colvuename="nom", $where=1) {
		   $option = "";
		   $sql = "SELECT " . $colvaluename . ", " . $colvuename . " FROM " . $tablename . " WHERE " . $where . " ORDER BY " . $colvuename;
		   $result = CBdd::select($sql);
		   while($array = mysql_fetch_array($result)) {
		   		$selected = CForm::get_selected($selectedvalue, $array[$colvaluename]);
		   		$option = $option . "<option value='" . $array[$colvaluename] . "'" . $selected . ">" . ucfirst(utf8_encode(substr($array[$colvuename], 0, 16))) . "</option>\n";
		   }
		   return $option;
	}	
开发者ID:rakotobe,项目名称:Rakotobe,代码行数:10,代码来源:CForm.php


示例18: create

 /**
  * Constructor
  *
  */
 public function create($successCallback, $values = null)
 {
     parent::__construct();
     $message = $values ? $values['message'] : "";
     $email = $values ? $values['email'] : "";
     $name = $values ? $values['name'] : "";
     $id = $values ? $values['id'] : "";
     $this->AddElement(new CFormElementText('message', ['value' => $message]))->AddElement(new CFormElementText('name', ['value' => $name]))->AddElement(new CFormElementText('email', ['value' => $email]))->AddElement(new CFormElementHidden('id', ['value' => $id]))->AddElement(new CFormElementSubmit('submit', array('callback' => $successCallback)))->AddElement(new CFormElementSubmit('submit-fail', array('callback' => array($this, 'DoSubmitFail'))));
     return $this;
 }
开发者ID:sebastianjonasson,项目名称:phpmvcprojekt,代码行数:14,代码来源:CommentForm.php


示例19: __construct

 /** Create all form elements and validation rules in the constructor.
  *
  */
 public function __construct()
 {
     parent::__construct();
     $items = array('tomato', 'potato', 'apple', 'pear', 'banana');
     $shoppingcart = array('potato', 'pear');
     foreach ($items as $item) {
         $this->AddElement(new CFormElementCheckbox($item, array('value' => $item, 'label' => $item, 'checked' => in_array($item, $shoppingcart))));
     }
     $this->AddElement(new CFormElementSubmit('submit', array('callback' => array($this, 'DoSubmit'))));
 }
开发者ID:Kajja,项目名称:phpmvc,代码行数:13,代码来源:test_checkbox1.php


示例20: create

 /**
  * Constructor
  *
  */
 public function create($successCallback, $user = null)
 {
     parent::__construct();
     $acronym = $user ? $user->acronym : "";
     $email = $user ? $user->email : "";
     $name = $user ? $user->name : "";
     $id = $user ? $user->id : "";
     $password = $user ? $user->password : "";
     $this->AddElement(new CFormElementText('acronym', ['value' => $acronym]))->AddElement(new CFormElementText('name', ['value' => $name]))->AddElement(new CFormElementText('email', ['value' => $email]))->AddElement(new CFormElementHidden('id', ['value' => $id]))->AddElement(new CFormElementPassword('password', ['value' => $password]))->AddElement(new CFormElementSubmit('submit', array('callback' => $successCallback)))->AddElement(new CFormElementSubmit('submit-fail', array('callback' => array($this, 'DoSubmitFail'))));
     return $this;
 }
开发者ID:sebastianjonasson,项目名称:phpmvcprojekt,代码行数:15,代码来源:UserForm.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP CFormElement类代码示例发布时间:2022-05-23
下一篇:
PHP CFilterChain类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap