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.
Related videos on Youtube
Author by
tnchalise
A computer Engineering student at Tribhuvan university.
Updated on June 17, 2022Comments
-
tnchalise almost 2 years
I am new in
YII
, i am wondering if the text-field inYII
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 over 11 yearsWorks.. But the editable cruser blinks over the text-filed. Any idea to remove that also?
-
bool.dev over 11 yearsthat 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 over 11 yearsExactly, the issue is browser dependency. Initially i tested in firefox. Now i realized. Thanks.
-
bool.dev over 11 yearsi 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