Theo số official tutorial của Yii2. Tôi đã tạo chế độ xem cho biểu mẫu nhập:Yii2 ActiveForm không hoạt động
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
?>
<?php $form = ActiveForm::begin(); ?>
<!-- GET Attention for the next Line -->
<?= $form->field($model, 'name')->label('Your Name'); ?>
<?= $form->field($model, 'email'); ?>
<div class="form-group">
<?= Html::submitButton('Send!', ['class' => 'btn btn-primary']); ?>
</div>
<?php ActiveForm::end(); ?>
Tại thời điểm này mọi thứ đều ổn. Tuy nhiên, khi tôi cố gắng sử dụng các tham số options
của phương pháp field
như sau:
<?= $form->field($model, 'name', ['style' => 'color:red'])->label('Your Name'); ?>
Tôi đã nhận lỗi:
Unknown Property – yii\base\UnknownPropertyException
Setting unknown property: yii\widgets\ActiveField::style
The official api documentation nói rằng phương pháp ActiveForm mất một tham số thứ ba được gọi là tùy chọn
Ai có thể giải thích cho tôi tại sao lỗi này đã xảy ra ?!
Cuộc thảo luận tài liệu chính thức về thông số thứ ba "tùy chọn". Nhưng nó không giải thích những gì có thể được xác định bằng cách sử dụng nó. :( – webpaul
Bạn nói đúng, cần phải có tài liệu tốt hơn. Tôi có thể thêm một số thứ vào tuần tới. –