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


PHP Pages::validate方法代码示例

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


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

示例1: actionCreate

 public function actionCreate()
 {
     //echo realpath(Yii::app()->baseUrl);            return;
     $model = new Pages();
     $this->layout = 'layout_user';
     // uncomment the following code to enable ajax-based validation
     /*
     if(isset($_POST['ajax']) && $_POST['ajax']==='pages-create-form')
     {
         echo CActiveForm::validate($model);
         Yii::app()->end();
     }
     */
     if (isset($_POST['Pages'])) {
         $model->attributes = $_POST['Pages'];
         if ($model->validate()) {
             $page = Pages::model()->find('id=:p_id', array(':p_id' => Yii::app()->session['pageId']));
             $page->company_name = $_POST['Pages']['company_name'];
             $page->type = $_POST['Pages']['type'];
             $page->address = $_POST['Pages']['address'];
             $page->description = $_POST['Pages']['description'];
             $page->save();
             // form inputs are valid, do something here
             return;
         }
     }
     $this->render('create', array('model' => $model));
 }
开发者ID:nomannoor,项目名称:social-property,代码行数:28,代码来源:PagesController.php

示例2: actionCreate

 public function actionCreate()
 {
     $this->breadcrumbs = array_merge($this->breadcrumbs, array('Создание страницы'));
     $this->pageTitle = Yii::t('app', 'Создание страницы');
     $model = new Pages();
     $modelLang = new PagesLang();
     if (Yii::app()->request->getPost('Pages')) {
         $model->attributes = Yii::app()->request->getPost('Pages');
         $modelLang->attributes = Yii::app()->request->getPost('PagesLang');
         $transaction = Yii::app()->db->beginTransaction();
         try {
             $model->validate();
             if (!$model->save()) {
                 throw new Exception('Ошибка при сохранении данных.');
             }
             $modelLang->page_id = $model->id;
             $modelLang->lang = Yii::app()->sourceLanguage;
             $modelLang->langs = "|" . Yii::app()->sourceLanguage . "|";
             if (!$modelLang->save()) {
                 throw new Exception('Ошибка при сохранении данных.');
             }
             $transaction->commit();
             Yii::app()->user->setFlash('success', Yii::t('app', 'Страница успешно создана'));
             Yii::app()->request->redirect($this->createUrl('index'));
         } catch (Exception $e) {
             $transaction->rollBack();
             $error = $e->getMessage();
         }
     }
     $this->render('create', array('model' => $model, 'modelLang' => $modelLang));
 }
开发者ID:Wiedzal,项目名称:araucano,代码行数:31,代码来源:DefaultController.php


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