I ran straight into a brick wall here. The setup: I have the controller "players". It lists all players, with a check box to tag invididual lines. I also have a select list to select a "raid" to add the players to. But I can''t get that data properly to the "raids" controller, which will handle the adding. Here''s the code, stripped down to the essentials: <%= form_tag :controller => ''raids'', :action => ''add_members'' %> <% for player in @players %> <%= check_box ''player'', ''id'', {}, player.id %> <% end %> <select><%= select_open_raids %></select> <%= submit_tag ''Assign'' %> <%= end_form_tag %> select_open_raids is just a simple function that returns the groups that are open right now: def select_open_raids @raids = Raid.find(:all, :conditions => "status = ''open''") options_from_collection_for_select(@raids, "id", "description") end Tailing the development log shows that I don''t get what I want in the parameters to the raids controller: Parameters: {"commit"=>"Assign", "player"=>{"id"=>"0"}, "action"=>"add_members", "controller"=>"raids"} For starters, no matter which players I choose, if any, it only passes :id => 0. check_box adds a hidden input field, and that screws this up. Do I have to write my own custom checkbox function for this? And the raids select box doesn''t appear in the parameters either. Suggestions and pointers, anyone? -- Johan Svensson atomicplayboy.net
your select box has no name ... thus should not be sending any values with the request. On 8/14/05, Johan Svensson <echo5ive-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I ran straight into a brick wall here. The setup: > > I have the controller "players". It lists all players, with a check > box to tag invididual lines. I also have a select list to select a > "raid" to add the players to. But I can''t get that data properly to > the "raids" controller, which will handle the adding. > > Here''s the code, stripped down to the essentials: > > <%= form_tag :controller => ''raids'', :action => ''add_members'' %> > <% for player in @players %> > <%= check_box ''player'', ''id'', {}, player.id %> > <% end %> > <select><%= select_open_raids %></select> <%= submit_tag ''Assign'' %> > <%= end_form_tag %> > > select_open_raids is just a simple function that returns the groups > that are open right now: > > def select_open_raids > @raids = Raid.find(:all, :conditions => "status = ''open''") > options_from_collection_for_select(@raids, "id", "description") > end > > Tailing the development log shows that I don''t get what I want in the > parameters to the raids controller: > > Parameters: {"commit"=>"Assign", "player"=>{"id"=>"0"}, > "action"=>"add_members", "controller"=>"raids"} > > For starters, no matter which players I choose, if any, it only passes > :id => 0. check_box adds a hidden input field, and that screws this > up. Do I have to write my own custom checkbox function for this? > > And the raids select box doesn''t appear in the parameters either. > Suggestions and pointers, anyone? > > -- > Johan Svensson > atomicplayboy.net > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > lists.rubyonrails.org/mailman/listinfo/rails >-- Zachery Hostens <zacheryph-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
On 8/15/05, Zachery Hostens <zacheryph-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: Well, I got it solved now. I made my own checkbox method that outputs <input type="checkbox" id="player_id" name="player[id][]" value="<%player.id %>"/> This gives me "player"=>{"id"=>["11", "12", "17"]} So I can select whichever checkboxes I need and get their associated id to the controller. -- Johan Svensson atomicplayboy.net