我有動態數量的問題和答案。我使用DynamicModel()來收集這些數據。將屬性標籤添加到DynamicModel Yii
$attributes = [
"answer_1" => "Some Value 1",
"answer_2" => "Some Value 2",
"answer_3" => "Some Value 3",
.....
]
$customFormModel = new DynamicModel($attributes);
我也有
$labels = [
"answer_1" => "Label 1",
"answer_2" => "Label 2",
"answer_3" => "Label 3",
.....
]
我只是不能得到$標籤陣列被設置爲標籤屬性爲我的動態模型。 我的$ customFormModel-> attributeLabels()總是空的。
這些結果包含以下問題。 我得到這樣的
Answer 1 can not be blank
Answer 2 can not be blank
Answer 3 can not be blank
錯誤消息我想,而不是
Label 1 can not be blank
Label 2 can not be blank
Label 3 can not be blank