Creating hidden fields using Drupal Form API

Dev

Creating hidden fields using Drupal Form API

by 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.

KeepWatch by InterWorks

Whether you need support for one platform or many, our technical experts have you covered.

More About the Author

Logan Lynn

Business Intelligence Consultant
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 ...
How to properly create a tinyint column with Drupal Schema API   Recently, I’ve been building a custom module to use on a customer’s site.  When I tried to install it I got the following ...

See more from this author →

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!