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

后端 未结 7 912
孤独总比滥情好
孤独总比滥情好 2021-02-12 10:55

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 11:56

    It works on my end:

    field($model, 'some_field')->textInput(['readonly' => true, 'value' => $model->isNewRecord ? 'Your Value' : $model->some_field]) ?>
    

提交回复
热议问题