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.
The readonly attribute makes a form control non-editable (or “read only”). A read-only field can't be modified, but, unlike disabled , you can tab into it, highlight it, and copy its contents. Setting the value to null does not remove the effects of the attribute. Instead use removeAttribute('readonly') .
The readonly attribute is a boolean attribute. When present, it specifies that an input field is read-only. A read-only input field cannot be modified (however, a user can tab to it, highlight it, and copy the text from it).
The Boolean readonly attribute, when present, makes the element not mutable, meaning the user can not edit the control.
According to HTML specs, the select tag in HTML doesn't have a readonly attribute, only a disabled attribute. So if you want to keep the user from changing the dropdown, you have to use disabled .
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With