Creating hidden fields using Drupal Form API

Creating hidden fields using Drupal Form API

//

Recently I was trying to create a hidden field on a form I’ve been working with and couldn’t find anything in the Drupal documentation that explained how to create a hidden form.  The solution is actually quite simple.

In this case I was using the hidden field to store a primary key value. 

$form[‘form_group’][‘form_name’] = array(

‘#title’ =>  t(‘ID’),

‘#value’ => $value,

‘#type’ => ‘hidden,

);

It’s as simple as setting the type to hidden.

SIGMA RAPID START

Switching your analytics to Sigma?
Speed up success with a Rapid Start!