0

I'm using Drupal 7 and have a custom content type that I've given authenticated users the ability to add and edit. Instead of giving them the ability to delete nodes, I've added a Boolean checkbox titled "Delete?" to the content type that they can check when editing the node. This prevents them from deleting a node without any administrative review. Is there anyway to hide this checkbox when they're adding a new node?

3

Implement hook_form_alter() and check whether $form['nid']['#value'] is empty, if empty then it is creation else it is update. If creation then hide the field by setting #access property to FALSE.

UPDATE : Create a custom module and use the following code with needed modification.

Here is an example to hide tags field in article content type.

function MYMODULE_form_alter(&$form, &$form_state, $form_id){
  if($form_id=='article_node_form' && empty($form['nid']['#value'])){
     $form['field_tags']['#access']=FALSE;
  }
}

Here is a tutorial on how to create a custom module.

  • So I'm fairly new to Drupal, where/how exactly would I implement hook_form_alter()? Or can you point me in the direction of a resource that explains how? Thanks a lot. – gussbus Jul 1 '14 at 17:43
  • @gussbus updated the answer – wolverine Jul 1 '14 at 17:46

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.