Closed (fixed)
Project:
Drupal core
Version:
7.x-dev
Component:
documentation
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
14 Oct 2007 at 20:26 UTC
Updated:
8 Jul 2009 at 18:00 UTC
http://api.drupal.org/api/file/developer/topics/forms_api_reference.html...
hidden
Description: Store data in a hidden form field.
Properties: #prefix, #suffix, #type, #value
#default_value is also a property. If you want to allow javascript to modify a hidden field's value, then you have to use #default_value to set the starting value when drawing the form. If you use #value, then javascript changes to the value will not be available in the form's _submit() function.
Comments
Comment #1
webchickIt's my understanding that giving a field type like hidden or value a #default_value is Very Very Dangerous (tm). I'll check with chx or eaton, but afaik this is a practice greatly discouraged. I'm not sure what the workaround is, however.
Comment #2
nielsbom commentedChanged the component to reflect the new component categorization. See http://drupal.org/node/301443
-nielsbom
Comment #3
add1sun commentedmoving to drupal queue for API docs.
Comment #4
jhodgdonLooking at the Drupal 7 source, I see both #value and #default_value being used.
From form_process_hidden_tabs():
From form_prepare_form():
It looks like the former example is for use with JavaScript, and the latter is a static value, so probably this reporter is correct.
I will update the form API docs accordingly.
Comment #5
jhodgdonI've fixed this in both the D6 and D7 versions of http://api.drupal.org/api/file/developer/topics/forms_api_reference.html/7
Changes checked into the contrib repository; should be live sometime in the next day or two on api.drupal.org.
Comment #6
jhodgdonhttp://drupal.org/cvs?commit=229250 for reference