Closed (fixed)
Project:
Webform
Version:
7.x-3.18
Component:
Miscellaneous
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
31 Mar 2013 at 00:20 UTC
Updated:
19 Jun 2013 at 02:09 UTC
My webform has a hidden field used to store an unique id. This id is generated from custom logic.
my code is to set this field value. 'webform_client_form_1' is my webform id
function webform_custom_form_webform_client_form_1_alter($form, $form_state, $form_id) {
$form['submitted']['test_id']['#value'] = 'COURSE_ID-123456';
}
When the form is submitted and view the submission result and this hidden field value is empty.
Comments
Comment #1
andyzhang commentedI was using the webform 7.15 and the following code worked.
$form['submitted']['test_id']['#default_value'] = 'COURSE_ID-123456';But after I upgrade webform to 7.18 and it can't get the test_id value in the submit function.
In 7.15, the hidden fields are converted to form's hidden fields while in 7.18 the hidden fields are converted to fapi's 'value' fields. That may cause the above code not to work. Can anybody suggest how to do it properly in 7.18? Thanks
Comment #2
quicksketchWe generally don't answer custom programming questions in the Webform issue queue. There's some specialized handling around hidden elements, if you have the component configured to use "Secure value (allows use of all tokens)" (the default), then you MUST use #value to alter its value. If you use "Hidden element (less secure, changeable via JavaScript)", you can change the value using #default_value, however I think #value will also work in that situation.
Comment #3
quicksketch