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.

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 →

Subscribe to our newsletter

  • I understand that InterWorks will use the data provided for the purpose of communication and the administration my request. InterWorks will never disclose or sell any personal data except where required to do so by law. Finally, I understand that future communications related topics and events may be sent from InterWorks, but I can opt-out at any time.
  • This field is for validation purposes and should be left unchanged.

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