dtv7174 2012-03-12 18:26
浏览 62
已采纳

如何用Yii中的数据库值填充文本字段?

I want to fill one of the textfields with a value from a database.

Commonly, this code was recommended:

<div class="row">
  <?php echo $form->labelEx($model,'field1'); ?>
  <?php echo Model1::model()->FindByPk($model->id)->field1;?>
  <?php echo $form->error($model,'field1'); ?>
</div>

But, the one I'm searching is the value is filled into textfield at the form.

Could anyone help me? Thanks..

  • 写回答

2条回答 默认 最新

  • duanbei8904 2012-03-12 18:36
    关注

    Try this:

    <?php echo Chtml::textField('txtFieldName', Model1::model()->FindByPk($model->id)->field1); ?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)
编辑
预览

报告相同问题?