I'm having a content type in that I want a field "Status" to be hidden in add content form page(I'm setting default value in that add content). Now I want that field to appear in edit form page of that node and user can able to edit it. I'm new to Drupal, so I don't know how to do this.


You can Show/Hide the status field using hook_form_alter like this:

function MYMODULE_form_node_form_alter(&$form, &$form_state) {
  $node = $form_state['node'];

  if (!isset($node->nid) || isset($node->is_new)) {
    $form['YOUR_FIELD']['#access'] = FALSE; // Node is new!
  else {
    $form['YOUR_FIELD']['#access'] = TRUE; // Node is not new!

Then replace YOUR_FIELD with the field name of your status field.

| improve this answer | |

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.