Non-Editable Text-Field
Asked Answered
F

1

7

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.

Fryd answered 21/12, 2012 at 5:48 Comment(0)
L
13

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.

Lesbian answered 21/12, 2012 at 5:51 Comment(4)
Works.. But the editable cruser blinks over the text-filed. Any idea to remove that also?Fryd
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?Lesbian
Exactly, the issue is browser dependency. Initially i tested in firefox. Now i realized. Thanks.Fryd
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 alsoLesbian

© 2022 - 2024 — McMap. All rights reserved.