I'm having an issue where a form post does not contain the value of the select box it contains. This problem happens after I update the the select box using an observe_field triggered ajax call. The result of the call is to call render :partial to re-generate just the select box element. If I post before triggering the ajax request I get all the correct parameters, afterwards, however I only get the commit, action and controller parameters. I have already cleared the usual suspects, forms improperly nested, etc.
If I have another element in the form but outside the partial that gets re-rendered it's value is submitted with the form. Along this line I figured I could have an on_change event on my select box so when someone selects a value it could get assigned to a hidden text field outside the partial. The javascript for all this works and I can verify the hidden text field has the correct value (using the Firebug javascript console) but when the form submits I get the original unmodified value of that hidden text field.
This is what my form looks like (the relevant parts that is). Yes I know these multiply nested tables for layout are hideous and it has caused me no end of grief on this project, however, I did not write them and I have absolutely no control over the html at this point (short of rewriting it all myself). The first form's submit is not relevant to this problem, just the org_id select box which triggers the re-rendering of the partial inside the td with the userdata id. I have tried making the target of the observe_field be a div, a span and a td all with the same effect.
<td height="175" align="left" valign="top"><table width="552" border="0" cellspacing="0" cellpadding="0" class="formcolumn"> <tr> <td width="87" height="25" align="left" valign="middle" class="formLabelText">Organizations:</td> <td height="25"><table width="323" height="25" border="0" cellpadding="0" cellspacing="0"> <%= start_form_tag :action=>"edit" %> <tr> <td width="173"><span class="date"> <%= select_tag "org_id", options_for_select(@orgs), :class=>'broadcast' %> <%= observe_field( :org_id, :url=>{:action=>'change_org'}, :update=>'userdata') %> </span></td> <td width="150"><span class="formLabelText"> <%= submit_tag "Edit", :class=>"inputsubmit" %> </span></td> </tr> <%= end_form_tag %> </table></td> </tr> <tr> <td height="25" align="left" class="formLabelText"> </td> <td height="25" align="left"> </td> </tr> <tr> <td height="25" align="left" class="formLabelText">Select User:</td> <td height="25"><table width="323" height="25" border="0" cellpadding="0" cellspacing="0"> <%= start_form_tag :controller=>"user", :action=>"modify" %> <tr> <td width="173"><span class="date" id="userdata"> <%= render :partial=>"user_select" %> </span></td> <%= text_field_tag "hiddenuser", "-1", :type=>"hidden" %> <td width="150"><span class="formLabelText"> <%= submit_tag "Edit", :class=>"inputsubmit" %> </span></td> </tr> <%= end_form_tag %> </table></td>
Here is the partial:
<%= select_tag "user_id", options_for_select(@users), :class=>'broadcast', :onchange=>"alert($('hiddenuser').text); $('hiddenuser').text = $('user_id').value; alert($('hiddenuser').text)" %>
Thanks in advance for any insights you can shed on this strange problem.
David Koontz Rising Tide Software