简体   繁体   中英

adding html id to form_tag rails 4

I currently have this sign in form in a rails 4 app in which I use the form_tag helper. I'm need to add an id. I tried using <%= form_tag( :html => {:id => 'login_form'} ) do %> but I get an error.

    <%= form_tag do %>
    <div class="form-group">
      <%= label_tag :name, 'Username:', class: "control-label" %>
      <div class="controls">
        <%= text_field_tag :name, params[:name], class: "form-control", size: "30", tabindex: "1" %>
      </div>
    </div>
    <div class="form-group">
      <%= label_tag :password, 'Password:' %>
      <div class="controls">
        <%= password_field_tag :password, params[:password], class: "form-control", size: "30", tabindex: "2" %>
      </div>
    </div>
    <div class="form-group">
      <div class="controls">
        <%= submit_tag "Sign in", class:"btn btn-large", tabindex: "2" %>
      </div>
    </div>
    <% end %>
<%= form_tag('/login', id: "login-form") do %>

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM