Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Non-Editable Text-Field

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.

like image 599
tnchalise Avatar asked Dec 21 '12 05:12

tnchalise


People also ask

How do I make a text field non-editable?

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') .

How do I make input field read only?

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).

Which attribute makes a field non-editable?

The Boolean readonly attribute, when present, makes the element not mutable, meaning the user can not edit the control.

How do you make a field not editable in HTML?

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 .


1 Answers

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.

like image 58
bool.dev Avatar answered Oct 05 '22 23:10

bool.dev