I'm using Rails 1.2.3 and have been wrestling with the form_tag helper trying to get the HTML id for the form set.
My form_tag initially looked like this:
<% form_tag :controller => 'my_controller', :action => 'my_action' do %>
and I thought it should be as easy as adding :html => {:id => 'my_id'}:
<% form_tag :controller => 'my_controller', :action => 'my_action', :html => {:id => 'my_id'} do %>
After all, that's how the form_remote_tag works:
<% form_remote_tag :controller => 'my_controller', :action => 'my_action', :html => {:id => 'my_id'} do %>
Much to my chagrin, it didn't work. I did a lot of searching and experimenting, and finally figured out that you have to make two changes to get it to work. First, you have to use a string literal for the url. Second, you can't specify the :html hash key:
<% form_tag '/my_controller/my_action', {:id => 'my_id'} do %>
Two questions:
1) Does anyone know why the form_tag helper is inconsistent with both the form_remote_tag helper and the more Rails-traditional way of specifying urls (:controller, :action)? 2) Does anyone know if this behavior has been changed in 2.0?
Peace, Phillip