Node form validates fields with #access = FALSE after ajax image upload I have a node form for a content type rendered using drupal_get_form(), I wanted to hide some fields so I altered this form and set attribute #access to FALSE in order to hide it and not validate it. 

Until this point everything goes nice but now I have a scenario that this form has an image field with ajax upload button, after removing / re-uploading the image the form validates the required fields that I already set its #access to FALSE.

I think that the form is rebuilt and all alteration to fields with #access = FALSE gone away. What should I do to avoid this?
You can use hook_form_alter() to hide the fields so that when the form is rebuilt (with AJAX or normal page load) the fields will still be hidden.

Also if you wanna make a field not validate then use the code below in your hook_form_alter() hook.

function mymodule_form_alter(&amp;$form, &amp;$form_state, $form_id){
  if($form_id == 'your_form_id'){
    // To hide the field
    $form['your_field']['#access'] = false;
    // To remove validation
    $form['your_field']['#required'] = false;
  }
}