I want to put a hook to a form on one specific form that I created. Based on Node ID. The code i currently have is .

  • Update own question & put more information. It is uncleare what are you asking.
    – Rupesh
    Sep 3, 2014 at 15:32
  • The hook that i have will apply to all forms at the moment. I just want it to apply to on particular page. ie., page-node-172 (i get this from fireBug) Sep 3, 2014 at 15:41

2 Answers 2


The $form array contains a #node key which has the nid attribute. Use that to filter like so:

if($form['#node']->nid == 1072) { ... }

However, since you ask for page-node-1072 it sounds like you want to put something in that particular page template, in which case you should use a process or preprocess function to add or alter variables for the template.


If you only want to alter the form on a single page @betherwisser 's answer is the right one. If you want to alter all pages of type webform_client_form, then leave out:

if (strpos($form_id, 'webform_client_form') !== FALSE) {}

and relpace it with the function hook_form_FORM_ID_alter. In your case:

jhumobileform_form_webform_client_form_alter(&$form, &$form_state, $form_id)

to find out the actual form_id (not sure whether 'webform_client_form' is the right one) install the devel module and activate it, then put dpm($form) in your function:

 function jhumobileform_form_alter(&$form, &$form_state, $form_id) { dpm ($form); //or directly dpm($form_id); } 

Then, navigate to the site of the form as admin. Within the $form array you can also find the #node key.

  • new idea. what if its using a specific theme? is there a way? Sep 10, 2014 at 3:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.