Compare FIELD value befaore saving the form - Form API

If you want to compare a field value with it self it was changed or not, you can do it using $node->original in hook_node_presave
function custom_node_presave($node) {
 if ($node->field_name == 1 && $node->original->field_name == 0) {
  //Do the magic here...
 }
}

Here I am comparing if checkbox was newly checked or was already checked. :)

Comments

Popular posts from this blog

How to Reset Root Password in Drupal 7 with phpMyAdmin

Drupal - Hiding field group and its Children