How do I create a hidden field programatically?
I don't follow the example 100%, but to answer the question - in D7 you can set '#type' =&gt; 'hidden', '#value' =&gt; 'foo' or just do '#my_custom_key' =&gt; 'my custom value' and it will be available to you in the submit handler (or elsewhere, such as hook_field_attach_submit()).