# Dynamic select box form field parameter not being submitted

**URL:** <https://www.ruby-forum.com/t/dynamic-select-box-form-field-parameter-not-being-submitted/89995>\
**Category:** Rails\
**Created:** [March 24, 2007, 8:25pm UTC](https://www.ruby-forum.com/t/dynamic-select-box-form-field-parameter-not-being-submitted/89995 "2007-03-24T20:25:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jeet](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/ad7895/32.png) [@jeet](https://www.ruby-forum.com/u/jeet)\
**Post date:** [March 24, 2007, 8:25pm UTC](https://www.ruby-forum.com/t/dynamic-select-box-form-field-parameter-not-being-submitted/89995/1 "2007-03-24T20:25:49Z")

</div>

I am trying to create a dynamic select box (contact\_preferences  
options list) based on a selection made in another select box (user  
contact\_preference\_opt\_in). I am using form\_for to build the form that  
has user contact\_preference\_opt\_in select box. The contact\_preferences  
options list select box is in a partial. I use observe\_field on first  
select box which calls an action (passes the selected value to it) to  
build an array used to populate the second drop down. All this works  
well but when I submit the form the second select box selection is not  
sent in the form (params).

Currently I am using the select helper (e.g.  
select(:user, :contact\_preference, @preferences) where @preferences  
array is populated in the action. Can I use this inside form\_for  
rather than f.select?

Seems like I can’t use f.select way of populating the select box in  
the partial as it does not know about the context of variable f when  
the partial is called from the action.

This should be common problem and I must be doing something wrong here.

---

<div class="post-metadata">

**Author:** ![jeet](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/ad7895/32.png) [@jeet](https://www.ruby-forum.com/u/jeet)\
**Post date:** [March 24, 2007, 9:11pm UTC](https://www.ruby-forum.com/t/dynamic-select-box-form-field-parameter-not-being-submitted/89995/2 "2007-03-24T21:11:53Z")

</div>

I fixed my problem.

The problem was that the form\_for helper was after the html

  
tag and before the tag. Because of that the form element for the  
second dropdown was somehow not being considered part of the form.  
Once I moved the form\_for helper before the 

|
| |

 ta everything was  
fine. Hope somebody else can benefit from this.
