views:

28

answers:

3

I'm using the form tag, and I want the result to be nomething like this:

<form action="controller/action" id="myID">

I currently have this

<% form_tag :action => '', :id=>"relative_date_filter" do |f| %>

which generates this:

<form action="/controller/relative_date_filter" method="post">

EDIT:
I currently get this error:

compile error
/app/views/controller/filters/_relative_time.html.erb:1: syntax error, unexpected tASSOC, expecting '}'
...e=true ;  form_tag {:action => ''}, {:id => "relative_date_f...
                              ^
/app/views/controller/filters/_relative_time.html.erb:1: syntax error, unexpected ',', expecting kEND
...e ;  form_tag {:action => ''}, {:id => "relative_date_filter...
                              ^
/app/views/controller/filters/_relative_time.html.erb:1: syntax error, unexpected kDO, expecting kEND
... => "relative_date_filter"} do ; @output_buffer.concat "\n  ...
                              ^
/app/views/controller/filters/_relative_time.html.erb:14: syntax error, unexpected kENSURE, expecting $end
Extracted source (around line #1):

1: <% form_tag {:action => ''}, {:id => "relative_date_filter"} do %>

Here, what is weird is that there is no line 14. its the end of the file. I added a return, and it changed to line 15. My previous code did cause the syntax error.

+2  A: 

This should work:

<% form_tag({:action => ''}, {:id => "relative_date_filter"}) do |f| %>
captaintokyo
This gives a compile error
DerNalia
Sorry, I was too fast... just a moment
captaintokyo
I updated my answer... can you try again?
captaintokyo
I still get an error, imma updtae my question with the error
DerNalia
You have to use braces around `{:action => ''}, {:id => "relative_date_filter"}` :-) updated and tested my answer.
captaintokyo
ha, just needed the ()
DerNalia
Bryce
A: 

The first parameter of form_tag is the url which is why you're seeing 'relative_date_filter' used for that. I think the extra options may allow you to specify an id.

<% form_tag({:action => ''}, {:id => 'relative_date_filter'}) do |f| %>

The first hash being the url and the second any extra options. This is also where the form method is supplied if you want anything other than post, for example.

Shadwell
This also gives a compile error. =\
DerNalia
I've added some brackets.
Shadwell
A: 
<%= form_tag ({:controller => 'public', :action => 'search'}), ({:class => "round_corners_8"}) do %>

This one is working for me in Rails 3.0

sNiCKY