0

I am using hook_form_alter() with custom submit handler (). At submit I want to check if there is any change in the content except node->expire then my custom code will run.

but at $form_state['value'] I am also getting: nid, vid, uid, created changed etc. and I have field type as taxonomy term reference and media files.

I do not want to hard-code the fields name as admin may add new fields later on.

0

Try comparing both $form_state[input] and $form_state['values'] .

After that check both values using the key's in foreach loop and compare both values, if changed then do your things there.

  • when I print value of taxonomy term reference for $form_state['input'] i get [field_catagories] => ( [und] => Array ( [31] => 31 [34] => 34 [22] => [26] => ) ) and when I print value of form_state['values'] my return value is field_catagories => ( [und] => Array ( [0] => Array ( [tid] => 31 ) [1] => Array ( [tid] => 34 ) ) ) How to compare – Anamika Nov 15 '16 at 15:00
  • Compare keys present then you will get 31 and 34 These two values are your inputted values. – Ajay Reddy Nov 16 '16 at 6:34

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.