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.
这应该工作:
<% form_tag({:action => ''}, {:id => "relative_date_filter"}) do |f| %>
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.
<%= form_tag ({:controller => 'public', :action => 'search'}), ({:class => "round_corners_8"}) do %>
这个在Rails 3.0中为我工作
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.