Yii $form->textfield, how to set a default value?

后端 未结 7 1460
心在旅途
心在旅途 2021-02-12 11:32

So I am fiddling with the Yii Framework and in one of the views, specifically the create form, I am trying to give one of my textfields a default value. Therefore when I go onto

相关标签:
7条回答
  • 2021-02-12 12:02

    It works on my end:

    <?= $form->field($model, 'some_field')->textInput(['readonly' => true, 'value' => $model->isNewRecord ? 'Your Value' : $model->some_field]) ?>
    
    0 讨论(0)
提交回复
热议问题