nid for custom form module
Forms don't have nid. Only nodes are having nid (node_id) in drupal. If you are displaying the form on any node page, suppose on http://example.com/node/123. Here 123 would be the node id and you can fetch it in form by 

if (arg(0) == 'node' &amp;&amp; is_numeric(arg(1))) {
  $nid = arg(1);
}


And if you want this $nid to be passed through different form states, add this as form field 

$form['nid'] = array('#type' =&gt; 'value', '#value' =&gt; $nid);