【问题标题】:Submit doesn't do anything提交没有任何作用
【发布时间】:2014-06-23 13:51:52
【问题描述】:

我正在使用 Rails 4、Bootstrap 3 和 Simple_form,由于某种原因,“提交”按钮没有提交任何内容。它甚至没有在服务器输出中生成任何东西供我调试。

这是我的代码:

<%= simple_form_for(@schedule) do |f| %>
<% if @schedule.errors.any? %>
<div id="error_explanation">
  <h2><%= pluralize(@schedule.errors.count, "error") %> prohibited this schedule from being saved:</h2>

  <ul>
    <% @schedule.errors.full_messages.each do |msg| %>
    <li><%= msg %></li>
    <% end %>
  </ul>
</div>
<% end %>

<form class="form-inline" role="form">
  <div class="form-group">

    <%= f.input :rating, collection: ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10"] %>
  </br>
    <%= f.input :thought, :input_html => {:rows => 10, :cols => 85} %>
  </div>

</form>


<div class="actions">
  <%= f.button :submit, "Create", :class => 'btn btn-primary'%>
</div>
<% end %>

这是我的模型:

class Schedule < ActiveRecord::Base
    validates :rating, :presence => true
    validates :thought, :presence => true
end

我确信这很简单,但我完全被难住了。

提前致谢。

【问题讨论】:

  • 可以在 HTML 中的表单中包含表单吗?

标签: ruby-on-rails ruby twitter-bootstrap simple-form


【解决方案1】:

删除这个

<form class="form-inline" role="form">  # <--- this another form begin
  <div class="form-group">

    <%= f.input :rating, collection: ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10"] %>
  </br>
    <%= f.input :thought, :input_html => {:rows => 10, :cols => 85} %>
  </div>

</form> # <--- this another form end

这段代码将你分成两种不同的形式。

【讨论】:

    猜你喜欢
    • 2012-05-07
    • 1970-01-01
    • 1970-01-01
    • 2018-06-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-02-04
    • 2020-03-14
    相关资源
    最近更新 更多