Search code examples
ruby-on-railsruby-on-rails-3form-helpers

How to use helpers in Form_tag helper?


I have written this code:

     <%=
        form_tag({:action => "simple_search", :method => 'get'}) do
    text_field_tag(:searchTextField, "Search by first name")

    submit_tag "Search", class: "edit_button"
        end
     %>

The problem I am facing is that submit tag is replacing the text_field tag, i.e. only submit tag appears, i want both of them to appear. What is wrong with code?

Regards


Solution

  • Try this:

    <%= form_tag({:action => "simple_search", :method => 'get'}) do %>
      <%= text_field_tag(:searchTextField, "Search by first name") %>
      <%= submit_tag "Search", class: "edit_button" %>
    <% end %>