Non-Editable Text-Field

11,110

Use readonly instead:

<?php echo $form->textField($model,'first_name',array('readonly' => true)); ?>

For no blinking, go for disabled attribute:

<?php echo $form->textField($model,'first_name',array('disabled' => true)); ?>

Both behave differently so be sure to check that out.

Share:
11,110

Related videos on Youtube

tnchalise
Author by

tnchalise

A computer Engineering student at Tribhuvan university.

Updated on June 17, 2022

Comments

  • tnchalise
    tnchalise almost 2 years

    I am new in YII, i am wondering if the text-field in YII can made non-editable. If so can anyone answer. I do the following way..

    <?php echo $form->labelEx($model,'first_name'); ?>
        <?php echo $form->textField($model,'first_name',array('setEnabled' => false)); ?>
    

    This is not working.

  • tnchalise
    tnchalise over 11 years
    Works.. But the editable cruser blinks over the text-filed. Any idea to remove that also?
  • bool.dev
    bool.dev over 11 years
    that is browser dependent, lemme see if i can find anything, no blinking in chrome(can't even select field), in firefox, can select, but no blinking, which browser are you testing in?
  • tnchalise
    tnchalise over 11 years
    Exactly, the issue is browser dependency. Initially i tested in firefox. Now i realized. Thanks.
  • bool.dev
    bool.dev over 11 years
    i made an edit, check it out, you wanted disabled in the beginning, so used it, just that you had tried with wrong code. For all htmlOptions, remember that html attributes are named exactly the same, as in if html attribute disabled exists, it'll be the same for htmlOptions also