Ejemplo n.º 1
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getAttributesAnswers()
 {
     return $this->hasOne(MembersAttributesAnswers::className(), ['attribute_id' => 'id']);
 }
Ejemplo n.º 2
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getMembersAttributesAnswers()
 {
     return $this->hasMany(MembersAttributesAnswers::className(), ['member_id' => 'id']);
 }
Ejemplo n.º 3
0
            <?php 
    //= $form->errorSummary($questionsAnswers);
    ?>
            <?php 
    //= $form->errorSummary($attributesAnswers);
    ?>

            <?php 
    /* output all attributes related tot the mapping category */
    ?>
            <?php 
    $member_id = Yii::$app->getUser()->id;
    foreach ($attributesModel as $model) {
        $value = $option_id = '';
        if ($answersModel = MembersAttributesAnswers::findOne(['attribute_id' => $model->id, 'member_id' => $member_id])) {
            $value = $answersModel->value;
            $option_id = $answersModel->option_id;
        }
        if ($model->fieldsTypes[0]->has_options) {
            //if question has options display a dropdown
            echo $form->field($attributesAnswers, "value_{$model->id}")->dropDownList(ArrayHelper::map(MembersAttributesToOptions::findAll(['attribute_id' => $model->id]), 'id', 'label'), ['prompt' => Yii::t('frontend', '-- Select --'), 'options' => [$option_id => ['Selected' => 'selected']]])->label($model->label);
        } else {
            // else if question does not have options display a text field
            if ($model->fieldsTypes[0]->title == 'Date Picker') {
                //@TODO replace datepicker with some database constatnt value;
                if (!empty($value)) {
                    $attributesAnswers->{"value_{$model->id}"} = date('F d Y', $value);
                }
                echo $form->field($attributesAnswers, "value_{$model->id}")->widget(DatePicker::className(), ['inline' => true, 'template' => '<div class="well well-sm" style="background-color: #fff; width:250px">{input}</div>', 'clientOptions' => ['autoclose' => true, 'format' => 'MM dd yyyy'], 'language' => Yii::$app->language]);
            } else {