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


PHP QuestionGroup::validate方法代码示例

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


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

示例1: actionUpdate

 /**
  * Mise  àjour d une fiche
  * @param $id the ID of the model to be displayed
  */
 public function actionUpdate($id)
 {
     $model = Questionnaire::model()->findByPk(new MongoID($id));
     $questionForm = new QuestionForm();
     $questionGroup = new QuestionGroup();
     // collect user input data
     if (isset($_POST['QuestionForm'])) {
         $questionForm->attributes = $_POST['QuestionForm'];
         //traitement ajout de question
         if ($questionForm->validate()) {
             $model = $this->saveQuestionnaireNewQuestion($model, $questionForm);
         }
     }
     if (isset($_POST['QuestionGroup'])) {
         $questionGroup->attributes = $_POST['QuestionGroup'];
         //copie du titre sur l option fr
         $questionGroup->title_fr = $questionGroup->title;
         if ($questionGroup->validate()) {
             $model = $this->saveQuestionnaireNewGroup($model, $questionGroup);
         }
     }
     //set du model sur la questionForm pour generer l arborescende de position de question
     $questionForm->questionnaire = $model;
     $this->render('update', array('model' => $model, 'questionForm' => $questionForm, 'questionGroup' => $questionGroup));
 }
开发者ID:Biobanques,项目名称:cbsd_platform,代码行数:29,代码来源:FicheController.php

示例2: actionUpdate

 /**
  * Mise  àjour d un formulaire /mode edition
  * @param $id the ID of the model to be displayed
  */
 public function actionUpdate($id)
 {
     $model = Questionnaire::model()->findByPk(new MongoID($id));
     $questionBlocForm = new QuestionBlocForm();
     $questionForm = new QuestionForm();
     $questionGroup = new QuestionGroup();
     // collect user input data
     if (isset($_POST['QuestionForm'])) {
         $questionForm->attributes = $_POST['QuestionForm'];
         if ($questionForm->validatewithId($model)) {
             if ($questionForm->help == "") {
                 $questionForm->help = null;
             }
             //traitement ajout de question
             if ($questionForm->validate()) {
                 $model = $model->saveQuestionnaireNewQuestion($questionForm);
             } else {
                 Yii::app()->user->setFlash('error', Yii::t('common', 'questionNotAdded'));
             }
         } else {
             Yii::app()->user->setFlash('error', Yii::t('common', 'questionNotAdded'));
         }
     }
     if (isset($_POST['QuestionGroup'])) {
         $questionGroup->attributes = $_POST['QuestionGroup'];
         if ($questionGroup->validatewithId($model)) {
             //copie du titre sur l option fr
             $questionGroup->title_fr = $questionGroup->title;
             if ($questionGroup->validate()) {
                 $model = $model->saveQuestionnaireNewGroup($questionGroup);
             }
         } else {
             Yii::app()->user->setFlash('error', Yii::t('common', 'tabNotAdded'));
         }
     }
     if (isset($_POST['QuestionBlocForm'])) {
         $questionBlocForm->attributes = $_POST['QuestionBlocForm'];
         if ($questionBlocForm->validatewithId($model)) {
             $questionBloc = QuestionBloc::model()->findByPk(new MongoId($questionBlocForm->title));
             $questionBlocForm->title_fr = $questionBlocForm->title;
             $computedGroup = new QuestionGroup();
             $computedGroup->copy($questionBlocForm, $questionBloc);
             if ($computedGroup->validate()) {
                 $model = $model->saveQuestionnaireNewGroup($computedGroup);
             }
             if (isset($questionBloc->questions) && $questionBloc->questions != null && count($questionBloc->questions) > 0) {
                 foreach ($questionBloc->questions as $question => $value) {
                     $currentQuestion = Question::model()->findByPk(new MongoId($value));
                     $questionForm->copy($currentQuestion, $computedGroup);
                     $model->saveQuestionnaireNewQuestionBloc($questionForm);
                 }
             }
         } else {
             Yii::app()->user->setFlash('error', Yii::t('common', 'tabNotAdded'));
         }
     }
     if (isset($_POST['old_onglet'])) {
         foreach ($model->questions_group as $onglet) {
             if ($onglet->id == $_POST['old_onglet']) {
                 $onglet->title = $_POST['new_onglet'];
                 $onglet->title_fr = $_POST['new_onglet'];
                 if ($model->save()) {
                     Yii::app()->user->setFlash('success', Yii::t('common', 'tabUpdated'));
                 } else {
                     Yii::app()->user->setFlash('error', Yii::t('common', 'tabNotUpdated'));
                 }
             }
         }
     }
     if (isset($_POST['old_question'])) {
         foreach ($model->questions_group as $onglet) {
             foreach ($onglet->questions as $question) {
                 if ($question->id == $_POST['old_question']) {
                     $question->label = $_POST['new_question'];
                     $question->label_fr = $_POST['new_question'];
                     if ($model->save()) {
                         Yii::app()->user->setFlash('success', Yii::t('common', 'questionUpdated'));
                     } else {
                         Yii::app()->user->setFlash('error', Yii::t('common', 'questionNotUpdated'));
                     }
                 }
             }
         }
     }
     //  set du model sur la questionForm pour generer l arborescende de position de question
     $questionForm->questionnaire = $model;
     $questionGroup->questionnaire = $model;
     $this->render('update', array('model' => $model, 'questionForm' => $questionForm, 'questionGroup' => $questionGroup, 'questionBloc' => $questionBlocForm));
 }
开发者ID:Biobanques,项目名称:cbsd_platform,代码行数:93,代码来源:FormulaireController.php


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