Friday, February 28, 2014

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. :)

No comments:

Post a Comment