I need the ability to grey out fields with non editable permission i.e. to show certain field values to the user but forbid him/her to edit them, upon node editing.

How can i achieve this?

  • You mean readonly field ? – Bala May 13 '13 at 8:01
  • Are you using D7 or D6 ? – Bala May 13 '13 at 8:04
  • Exactly. Field permissions give the ability to leave unchecked the "edit own field" permission but this results to hiding the field. I want that field to be readonly as a reminder for the user. Using D7... – Billy May 13 '13 at 8:07

Form elements have a disabled property you can set as a boolean. For example:

$form['test'] = array(
  '#type' => 'text',
  '#title' => t('Test'),
  '#required' => FALSE,
  '#default_value' => 0,
  '#disabled' => TRUE,

Now, you can use hook_form_alter() to check that you're on the right form ($form_id), and any other conditions you require, like for instance checking user permissions, with the user_access() function.


I think the fastest way to achieve what You want is to use jQuery in Your template or custom module:


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.