public function actionGetOptionsList()
 {
     $id = Yii::$app->request->post('id', null);
     $optionsHtml = '';
     if (!empty($id) && $id > 0) {
         $options = MappingQuestionsToOptions::find()->where(['question_id' => $id]);
         if ($options->count() > 0) {
             $optionsList = $options->all();
             $optionsHtml .= '<option>' . Yii::t('backend', 'Select Options') . '</option>';
             foreach ($optionsList as $option) {
                 $optionsHtml .= "<option value='" . $option->id . "'>" . $option->title . "</option>";
             }
         } else {
             $optionsHtml .= "<option> - </option>";
         }
     }
     echo $optionsHtml;
 }
 /**
  * Finds the MappingQuestionsToOptions model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return MappingQuestionsToOptions the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = MappingQuestionsToOptions::find()->where(['id' => $id])->multilingual()->one()) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Beispiel #3
0
                                                            $("select#pdfsrules-options_id").html(data);
                                                        })'];
$answers_options = ['prompt' => Yii::t('backend', 'Select Answers'), 'multiple' => 'true', 'size' => 7];
$questions_condition['fields_type.has_options'] = 1;
if (!empty($model->category_id)) {
    $category_options['options'] = [$model->category_id => ['Selected' => 'selected']];
    $questions_condition['category_id'] = $model->category_id;
    $question_options['options'] = [$model->question_id => ['Selected' => 'selected']];
    $answers_condition['question_id'] = $model->question_id;
    $answers_options['options'] = [$model->options_id => ['Selected' => 'selected']];
}
$question_items = array();
$options_items = array();
if (!$model->isNewRecord) {
    $question_items = \yii\helpers\ArrayHelper::map(\backend\models\MappingQuestions::find()->joinWith('fieldsTypes')->where($questions_condition)->all(), 'id', 'title');
    $options_items = \yii\helpers\ArrayHelper::map(\backend\models\MappingQuestionsToOptions::find()->where($answers_condition)->all(), 'id', 'title');
}
?>

    <?php 
echo $form->field($model, 'category_id')->dropDownList(\yii\helpers\ArrayHelper::map(\backend\models\MappingCategories::find()->all(), 'id', 'name'), $category_options)->label(Yii::t('backend', 'Select Categories'));
?>

    <?php 
echo $form->field($model, 'question_id')->dropDownList($question_items, $question_options)->label(Yii::t('backend', 'Select Question'));
?>

    <?php 
echo $form->field($model, 'options_id')->dropDownList($options_items, $answers_options)->label(Yii::t('backend', 'Select Answers'));
?>
Beispiel #4
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getPdfOptions()
 {
     return MappingQuestionsToOptions::find()->where(['id' => $this->options_id])->multilingual()->one();
 }