Creating hidden fields using Drupal Form API

Creating hidden fields using Drupal Form API

Logan Lynn
//

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.

Need Expert Help?

See Our Full Menu of Data Services

InterWorks uses cookies to allow us to better understand how the site is used. By continuing to use this site, you consent to this policy. Review Policy OK

×

Interworks GmbH
Ratinger Straße 9
40213 Düsseldorf
Germany
Geschäftsführer: Mel Stephenson

Kontaktaufnahme: markus@interworks.eu
Telefon: +49 (0)211 5408 5301

Amtsgericht Düsseldorf HRB 79752
UstldNr: DE 313 353 072

×

Love our blog? You should see our emails. Sign up for our newsletter!