By meetsagar on
I have a text field which displays the username. The user should not be able to edit the text field values. Can anyone help me on this?
Thanks,
Sagar.
I have a text field which displays the username. The user should not be able to edit the text field values. Can anyone help me on this?
Thanks,
Sagar.
Comments
...
Where exactly does this field appear?
If it's the one in the profile page, you should go to the permissions settings and un-check the relevant permission.
#attributes
Hi,
You could try adding one of the following attributes to your text field:
http://www.w3.org/TR/html4/interact/forms.html#adef-readonly
http://www.w3.org/TR/html4/interact/forms.html#adef-disabled
- p
Thanks
I am able to disable the text field.
Thanks for the quick reply. Thanks a lot.
Thanks,
Sagar.
Thank your. I have been
Thank your.
I have been trying
'#readonly' => ture,
'#readonly' => readonly,
Is not correct..
but use '#disabled' => ture, Is feasible
Thank you very much ..
'#attributes' => array('readonly' => 'readonly'),
Thanks
'#disabled' => TRUE, is work
'#attributes' => array('disabled' => 'disabled')
edian tenan...
it's work, the field became grey, thank's
Node type article : title will be non editable for editor role
function alter_form_alter(&$form, &$form_state, $form_id) {
switch ($form_id) {
case 'article_node_form': // content type article check with dsm($form)
global $user;
if (in_array('editor', array_values($user->roles))) {
$form['title']['#disabled'] = TRUE;
}
break;
}
}
use '#disabled' => TRUE" or '#attributes' => array('readonly)
$form['billing-address'] = array(
'#type'=> 'textfield',
'#title' => t('Your Billing Address is '),
//'#disabled' => TRUE, its working & its show grey color
'#attributes' => array('readonly' => 'readonly'),
'#default_value' =>$bill,
);