I’ve got a form with an input with id/name league_id:
<form accept-charset="UTF-8" action="/user" method="post">
<div style="margin:0;padding:0;display:inline">
<input name="utf8" type="hidden" value="✓">
<input name="authenticity_token" type="hidden" value="bb92urX83ivxOZZJzWLJMcr5ZSuamowO9O9Sxh5gqKo=">
</div>
<input id="league_id" name="league_id" type="text" value="11">
<select class="sport_selector" id="sport_type_id" name="sport_type_id">
<option value="5" selected="selected">Football</option>
<option value="25">Women's Soccer</option>
<option value="30">Volleyball</option>
<option value="10">Men's Soccer</option>
</select>
<input name="commit" type="submit" value="Save changes">
</form>
In another part of my page, I have a drop down that, when changed, clears the value of league_id:
$("#sport_type_id").change(function(){
$("#league_id").val(null)
$(this).parents('form:first').submit()
});
If I debug this page, I can see the value get wiped from the text box, but when the form is submitted, my controller always gets the old value.
UPDATE
My fault. I had multiple fields labeled league_id. Not sure exactly what was going on, but I started getting really weird results when I typoed something, and once I ensured all the ID’s were unique, I started getting the expected results.
Sorry for the face-palm
I tried changing the name of the input and got the same results.
My own fault, had a name collision in the elements