In content type testtype I have 2 required field: field_one & field_two.

I need to make field_one only enabled on node submit, while field_two only enabled on node edit.

So, when submitting, we can only see field_one, and when editing, we can only see field_two

  • Got it using form_alter – apasajja Feb 24 '13 at 19:59
  • The difference between submit and edit is not clear in your question. – David Thomas Feb 24 '13 at 21:29
  • @David Thomas, Node submit node/add/testtype, while node edit node/<nodeid>/edit. I've solved the problem by form_alter – apasajja Feb 25 '13 at 3:31

you can solve this problem in different ways.

The first is quite easy: you can show/hide the fields from CSS.

When you create a node, the default body classes contain this CSS class: "page-node-add". Instead when you edit a node you'll have the class "page-node-edit".

So you can add this CSS code:

.page-node-add .field_two{ display:none } 
.page-node-edit .field_one{ display:none } 

This solution is not elegant and it could be a potential security hole.

A better solution is to implement hook_form_alter() from your theme or from a custom module.

The code could be something like:

function yourmodulename_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'testtype_node_form' && arg(1) == 'add' ) {
    $form['field_two']['#access'] = 0;
  if ($form_id == 'testtype_node_form' && arg(2) == 'edit' ) {
    $form['field_one']['#access'] = 0;

Good work!


I had almost the same situation today and field permission did the job perfectly.

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.