Seeing if node has been changed in custom submit handler I have written a custom submit handler that gets called whenever a certain content type is edited.

I was wondering if there was a flag in $form_state that indicates whether the node was actually edited vs whether someone is just clicking the save button without actually changing anything.  I am wondering because I would like to perform an action only if the node is edited. Thank you

function hook_form_alter(&amp;$form, &amp;$form_state, $form_id) {
  $form['#submit'][] = '_unpublish_new_product';
}

function _unpublish_new_product($form, &amp;$form_state) {
   // is there a flag in $form_state that indicates if any fields were changed so I
   // could perform a conditional action??
}
As far as I know, there isn't such flag, but you can use entity_load_unchanged() to get a copy of the entity before any change, and compare the field value with the one you get from the form.

The function is called, for example, from node_save(), which contain the following code.

// Load the stored entity, if any.
if (!empty($node-&gt;nid) &amp;&amp; !isset($node-&gt;original)) {
  $node-&gt;original = entity_load_unchanged('node', $node-&gt;nid);
}

field_attach_presave('node', $node);
global $user;

// Determine if we will be inserting a new node.
if (!isset($node-&gt;is_new)) {
  $node-&gt;is_new = empty($node-&gt;nid);
}

// Set the timestamp fields.
if (empty($node-&gt;created)) {
  $node-&gt;created = REQUEST_TIME;
}
// The changed timestamp is always updated for bookkeeping purposes,
// for example: revisions, searching, etc.
$node-&gt;changed = REQUEST_TIME;

$node-&gt;timestamp = REQUEST_TIME;
$update_node = TRUE;

// Let modules modify the node before it is saved to the database.
module_invoke_all('node_presave', $node);
module_invoke_all('entity_presave', $node, 'node');


This means that the implementations of hook_field_attach_presave(), hook_node_presave(), and hook_entity_presave() will get the unchanged version of the node object in $node-&gt;original (or $entity-&gt;original); if you are writing code for one of these hooks, you don't need to call entity_load_unchanged() because node_save() already did it for you.

Similar code is present in comment_save(), taxonomy_term_save(), taxonomy_vocabulary_save(), and user_save().

if (!empty($comment-&gt;cid) &amp;&amp; !isset($comment-&gt;original)) {
  $comment-&gt;original = entity_load_unchanged('comment', $comment-&gt;cid);
}

field_attach_presave('comment', $comment);

// Allow modules to alter the comment before saving.
module_invoke_all('comment_presave', $comment);
module_invoke_all('entity_presave', $comment, 'comment');




  if (!empty($term-&gt;tid) &amp;&amp; !isset($term-&gt;original)) {
    $term-&gt;original = entity_load_unchanged('taxonomy_term', $term-&gt;tid);
  }

  field_attach_presave('taxonomy_term', $term);
  module_invoke_all('taxonomy_term_presave', $term);
  module_invoke_all('entity_presave', $term, 'taxonomy_term');