Submit button does not work unless I refresh the page form_for Rails

后端 未结 2 1258
遇见更好的自我
遇见更好的自我 2021-01-04 05:07

I have an app that has a problem model and when I go to create a record the submit button does nothing. No errors given it just simply doesnt execute, unless I refresh the p

相关标签:
2条回答
  • 2021-01-04 05:51

    I had same issue

    Before

    <%= simple_form_for(:schedule_list, url: schedulelists_create_with_block_path, :html => { novalidate: false}) do |f| %> 
    <div class="row">
      <div class="col-md-12">
        <%= f.button :submit, class: 'pull-right' %>
        <%end%>
      </div>
    </div>
    

    After

    <%= simple_form_for(:schedule_list, url: schedulelists_create_with_block_path, :html => { novalidate: false}) do |f| %> 
        <div class="row">
          <div class="col-md-12">
            <%= f.button :submit, class: 'pull-right' %>
          </div>
        </div>
    <%end%>
    
    0 讨论(0)
  • 2021-01-04 05:52

    Your HTML is invalid, the submit button is actually not nested under the form tag. Try changing your view code to this:

    <div class="row">
      <div class="large-12 columns">
        <%= form_for @problem do |f| %>
          <label>Name</label>
          <%= f.text_field :name, placeholder: "Name your problem!" %>
          <div class="large-8 columns">
            <%= f.text_field :url, placeholder: "Link to any supporting material" %>
          </div>
          <div class="large-12 columns">
            <%= f.text_area :description %>
          </div>
          <div class="large-12 columns">
            <%= f.submit "Create" %>
          </div>
        <% end %>
      </div>
    </div>
    
    0 讨论(0)
提交回复
热议问题