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?
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
-