On 7 March 2010 11:00, Ralph Shnelvar <[email protected]> wrote: > Colin Law wrote: >> I think maybe you cannot include query terms in form_for :url. An >> alternative is to use hidden fields in the form. > > Colin, thank you. You appear to be correct. > > So for the next poor person fighting to get internationalization to work > (I18n. See http://guides.rubyonrails.org/i18n.html Section 2.3 Setting > and Passing the Locale) .. > > form_for cannot be, uh, "internationalized" because the various flavors > of url_for that I18n hooks will have the locale parameter disappear if a > form, any form, is used. It appears not to be an ruby/rails/I18n problem > but an arcane "problem" in html. > > Thus ... if you want to pass a couple of extra parameters when using > form_for ... you can do what I did. I'm pasting in my adlterated code: > > - - - - - - - > <% form_for @countryToSearchFor, > :url => signed_in_path(:action => "show", :id => > 'connected_to_country'), > :html => {:method => :get} do |f| %> > <input type="hidden" name="locale" value="<%= params[:locale] %>" > > <input type="hidden" name="somename" value="someothervalue" > > <%= f.select :country, > language_neutral_array_of_countries, > :prompt => shnI18n.literal('enter_country') %> > <br /> > <br /> > <div> > <%= f.submit shnI18n.literal('search_for_connection') %> > </div> > <% end %> > - - - - - - - > > You will note the > <input type="hidden" name="locale" value="<%= params[:locale] %>" > > <input type="hidden" name="somename" value="someothervalue" > > > The first <input> is the critical one where the locale is being passed. > The second <input> simply shows how to pass :somename => > "someothervalue". > > Both parameters (locale, somename) will end up in the params received by > the relevant controller. > > - - - > > I find using raw html to be far far easier to understand and more > convenient to use than the hidden_field api documented in > http://api.rubyonrails.org/classes/ActionView/Helpers/FormHelper.html.
What is wrong with <%= hidden_field_tag "locale", params[:locale] %> Colin -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

