Cannot set hidden form field in symfony using jquery
I have a hidden form field called patient_开发者_JS百科id which I need to set using jquery. I set it using the following code along with another 2 fields :
$('#investigation_patient_id').val($('#patient_id').html());
$('#patient_first_name').val($('#patient_fname').html());
$('#patient_last_name').val($('#patient_sname').html());
When I do an alert on $('#investigation_patient_id') it alerts the correct value. Although when I inspect the field in firebug after setting it, there is no value attribute, never mind a value for that. But when I inspect the other fields set above, they have the right value.
When I submit the form then do a die statement:
die($request->getPostParameter("investigation[patient_id]"));
the die statement is blank, though if I die on the other form fields I set, they show up. A print_r of $request also shows the value of patient_id is blank.
So what's going on? Why can't I set a hidden form field?
Thanks for the comments, it was my mistake, I had two inputs with the same name and id - I hadn't realised that symfony automatically generates hidden fields, meaning I had then I rendered them too, thus two identical inputs
精彩评论