我在rails中创建一个简单的表单,并且提交按钮不起作用。我想我在这里遗漏了一些明显的东西,但html似乎很好(我远远超过了前端专家)。有什么建议或指示吗?
<div class="container">
<div class="row">
<div class="col-lg-12 text-center">
<h2>Apply</h2>
<hr class="star-primary">
</div>
</div>
<div class="row">
<div class="col-lg-8 col-lg-offset-2">
<div class="row control-group">
<% if @user.errors.any? %>
<div id="error_explanation">
<div class="alert alert-error">
The form contains <%= pluralize(@user.errors.count, "error") %>.
</div>
<ul>
<% @user.errors.full_messages.each do |msg| %>
<li>* <%= msg %></li>
<% end %>
</ul>
</div>
<% end %>
<div class="col-xs-12 floating-label-form-group controls">
<%= form_for @user, url: users_path(@user), :html => {:method => :post} do |f| %>
<%= f.label :name %>
<%= f.text_field :name, class: "form-control", placeholder: 'Name' %>
<%= f.label :email%>
<%= f.text_field :email, class: "form-control", placeholder: "Email" %>
<%= f.label :address%>
<%= f.text_field :address, class: "form-control", placeholder: "Address" %>
<%= f.label :phone %>
<%= f.text_field :phone, class: "form-control", placeholder: "Phone Number" %>
<%= f.submit "Apply"%>
<%end%>
</div>
</div>
</div>
</div>
</div>
此外,当提交按钮失败时,没有任何反应。没有错误消息,没有控制台错误。没有。
答案 0 :(得分:1)
从method
哈希中取出html
?
form_for @user, url: users_path(@user), :method => :post do |f|
答案 1 :(得分:0)
试试这个:
<%= form_for @user, :url => {:controller => "your-controller-name", :action => "your-action-name"} do |f| %>
答案 2 :(得分:0)
你能试试这个:
<%= form_for @user, url: {action: "create"} do |f| %>
...
...
<%= f.submit "Apply" %>
<% end %>
但我强烈建议您使用simple_form gem。