本文整理汇总了PHP中Question::setAttributesByQuestionForm方法的典型用法代码示例。如果您正苦于以下问题:PHP Question::setAttributesByQuestionForm方法的具体用法?PHP Question::setAttributesByQuestionForm怎么用?PHP Question::setAttributesByQuestionForm使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Question
的用法示例。
在下文中一共展示了Question::setAttributesByQuestionForm方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testTypeFunction
/**
* testing method return array type
*/
public function testTypeFunction()
{
$model = new Question();
$questionForm = new QuestionForm();
$questionForm->id = "q1";
$questionForm->label = "Question 1";
$questionForm->type = "input";
$questionForm->style = "";
$questionForm->values = "";
$questionForm->precomment = "";
$questionForm->precomment_fr = $questionForm->precomment;
$questionForm->help = "";
$model->setAttributesByQuestionForm($questionForm);
$this->assertInternalType('object', $model->model());
$this->assertInternalType('array', $model->rules());
$this->assertInternalType('array', $model->attributeLabels());
$this->assertInternalType('object', $model);
}
示例2: saveBlocNewQuestion
public function saveBlocNewQuestion($bloc, $questionForm)
{
var_dump($bloc);
$cquestion = new Question();
$cquestion->setAttributesByQuestionForm($questionForm);
$bloc->questions = $questionForm->id;
if ($bloc->save()) {
Yii::app()->user->setFlash('success', Yii::t('common', 'questionBlockSaved'));
} else {
Yii::app()->user->setFlash('error', Yii::t('common', 'questionBlockNotSaved'));
}
return $bloc;
}
示例3: saveQuestionnaireNewQuestion
/**
* save a new question into the questionnaire
* si pas de positionnement on ajoute la questionen au debut du groupe
* @param questionnaire
*/
public function saveQuestionnaireNewQuestion($questionnaire, $questionForm)
{
$questionnaire->last_modified = DateTime::createFromFormat('d/m/Y', date('d/m/Y'));
$cquestion = new Question();
$cquestion->setAttributesByQuestionForm($questionForm);
Yii::log("save questionnaire", CLogger::LEVEL_TRACE);
//si pas de position fournie, on ajoute la question a la fin, dans le premier groupe de question
if (!isset($questionForm->idQuestionBefore) || empty($questionForm->idQuestionBefore)) {
if ($questionnaire->questions_group != null && count($questionnaire->questions_group) > 0) {
foreach ($questionnaire->questions_group as $group) {
if ($group->id == $questionForm->idQuestionGroup) {
if ($group->questions == null) {
$group->questions = array();
$group->questions[] = $cquestion;
} else {
array_unshift($group->questions, $cquestion);
}
}
}
}
} else {
//sinon positionnement relatif
if ($questionnaire->questions_group != null) {
foreach ($questionnaire->questions_group as $group) {
if ($group->questions != null) {
foreach ($group->questions as $key => $question) {
if ($question->id == $questionForm->idQuestionBefore) {
array_splice($group->questions, $key + 1, 0, array($cquestion));
}
}
}
}
}
}
if ($questionnaire->save()) {
Yii::app()->user->setFlash('success', Yii::t('common', 'questionDeleted'));
} else {
Yii::app()->user->setFlash('error', Yii::t('common', 'questionNotDeleted'));
Yii::log("pb save answer" . print_r($answer->getErrors()), CLogger::LEVEL_ERROR);
}
return $questionnaire;
}