这是我的activeRadioList
<?= Html::activeRadioList($model, 'qa_value', ot\QuestionAnswer::getAnswerOptions($model), [
'encode' => false,
'separator' => '<br/>',
'itemOptions' => [
'labelOptions' => ['class' => 'radio-inline']
],
]); ?>
这是我的getAnswerOption()
函数来获取选项值
public static function getAnswerOptions($qModel)
{
$answerData = $qModel->qaQuestionInstance->getTqiQuestionAns()->asArray()->all();
return \yii\helpers\ArrayHelper::map($answerData, 'qna_id', function ($model) {
$l = 'a';
return $l++.'. '.$model['qna_answer'];
});
}
这是这样的回报
但我想要
一个。错误
湾真
答案 0 :(得分:0)
是的,我在getAnswerOptions()
功能
public static function getAnswerOptions($qModel)
{
$answerData = $qModel->qaQuestionInstance->getTqiQuestionAns()->asArray()->all();
$l = 'a';
$i = 0;
foreach ($answerData as $ad)
{
$answerData[$i++]['qna_answer'] = ($l++.'. '.$ad['qna_answer']);
}
return \yii\helpers\ArrayHelper::map($answerData, 'qna_id', function ($model) {
return $model['qna_answer'];
});
}