In Drupal's Form API page mentioned both hidden and value will not display to user.

What is the difference between them?

2 Answers 2


With the hidden form element, the HTML markup added in the form is <input type="hidden" /> (including other HTML attributes).
With the value form element, nothing is added to the form markup.

In both the cases, there are no form elements visible to the users. The difference is that the value form element is simply kept in the cache Drupal uses for forms created with the form API; nothing is sent to the browser.

Generally, the hidden form element is used for values that are used from JavaScript code, but that must be non editable nor visible in the form.


When you define something as hidden it is actually there in the html as an of hidden type. but when you define it as value it is not rendered in the form.

Both values are passed to the form_state the value would be there in the $form_state['values']

I am not sure what would be a use case for the same. May be a value that is internal to the form and does not need to be even a hidden input.

  • It's useful to have when a value is needed when submitting the form (like a record ID), but is otherwise not something that is ever edited.
    – jgreep
    Jun 28, 2018 at 19:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.