Forum: Ruby on Rails end_form_tag

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
A111108ed3617edc35da89e84689c3c2?d=identicon&s=25 Arch Stanton (d6veteran)
on 2007-04-03 18:12
In my logs I can see that end_form_tag is being deprecated.  I wanted to
make the switch now but cannot get the new end tag to work.

THIS WORKS:

    <%= form_remote_tag :url =>{:action => "next_question",
                                :kwiz_id => @kwiz.id,
                                :position => @next_position} %>

        <% @question.choices.each do |choice| -%>
            <%= radio_button_tag "choice_id", choice.id %>
            <%= choice.name %><br />
        <% end -%>
        <br />
        <%= submit_tag "Next Question" %>
    <%= end_form_tag %>


THIS DOES NOT WORK:

    <%= form_remote_tag :url =>{:action => "next_question",
                                :kwiz_id => @kwiz.id,
                                :position => @next_position} %>

        <% @question.choices.each do |choice| -%>
            <%= radio_button_tag "choice_id", choice.id %>
            <%= choice.name %><br />
        <% end -%>
        <br />
        <%= submit_tag "Next Question" %>
    <%= end %>
Cde0427edc3138a49ec9f07a07b7079f?d=identicon&s=25 Niels Meersschaert (Guest)
on 2007-04-03 18:17
(Received via mailing list)
Remove the = it isn't supposed to write out end, only close the loop,
thus you want

<% end %> instead of <%= end %>
A111108ed3617edc35da89e84689c3c2?d=identicon&s=25 Arch Stanton (d6veteran)
on 2007-04-03 18:21
Niels Meersschaert wrote:
> Remove the = it isn't supposed to write out end, only close the loop,
> thus you want
>
> <% end %> instead of <%= end %>


That doesn't work either :(
2b4ba7df1d18f7ecbb5d2859aa0cfc7d?d=identicon&s=25 tharealpatton (Guest)
on 2007-04-03 18:32
(Received via mailing list)
<% form_remote_tag :url =>{:action => "next_question"} do %>
# Form contents...
<% end %>

Form tag helpers should not use <%= %> if you're trying to pass them a
block.  They should use <% %>.

Alternatively, you could use:

<%= form_remote_tag :url =>{:action => "next_question"} %>
# Form contents...
</form>

But that's not as pretty.  See DHH's article on the topic:
http://www.loudthinking.com/arc/2006_10.html

See also the following for examples of the syntax:
http://api.rubyonrails.org/classes/ActionView/Help...

Hope this helps.

-PJ
This topic is locked and can not be replied to.