我剛剛啓動Yii2框架。
我想創建一個1到10的下拉列表和一個提交按鈕
一旦選擇了該選項並點擊按鈕應該轉到下一頁來顯示我選擇的數字。yii2:未定義變量:model
在我看來文件:在下拉列表中有:index.php文件
use yii\widgets\ActiveForm;
<?php $form = ActiveForm::begin(); ?>
<?= $form->field($model, 'QTY')->dropDownList(range(1, 10)) ?>
<?= Html::submitButton('Buy', ['class' => 'btn btn-primary']) ?>
<?php ActiveForm::end(); ?>
然後當我去它給我的頁面「的模式未定義的變量」。
我該怎麼做才能使其正確?
Html和CHtml有什麼不同?
謝謝。
'Activeform'中使用的字段應該與'model'關聯。顯示呈現視圖的控制器動作。 –
嗨,謝謝,我已經發現了錯誤。 –