Rails disable_with在模态内的表单中不起作用

时间:2012-06-15 19:48:01

标签: ruby-on-rails forms simple-form

我遇到了disable_with的问题。 我在一个模态中有一个simple_form,而disable_with没有工作

但是在模态中的form_tag中它运行良好

这是我的代码

>  <div class="modal-header">       <%= link_to '×', '#', class: 'close', data: {dismiss: 'modal'}, rel: 'tooltip', title: t(".close") %>  
>   <h3><%= t(".title")%></h3>   </div>
> 
>   <div class="modal-body">    <%= simple_form_for(@user_address, url:
> update_addresses_path, remote: true, method: :put, html: {class:
> 'form-horizontal'}) do |f| %>
>           <%= hidden_field_tag :id, @user_address.id %>
>           <%= f.input :nickname %>    
>           <%= f.input :address %>
>           <%= f.input :number %>
>           <%= f.input :complement %>
>           <%= f.input :neighborhood %>
>           <%= f.input :postal_code %>
>           <%= f.association :state, collection: State.all(order: :symbol), label_method: :symbol, input_html: {id: "state_id_order"} %>
>           <%= f.input :city_id, collection: State.all(order: :symbol), as: :grouped_select, group_label_method: :symbol, group_method: :cities, 
> include_blank: true, input_html: {id: "city_id_order"} %>   </div>
> 
>     <div class="modal-footer">
>       <%= link_to_cancel "#", data: {dismiss: "modal"} %>
>       <%= f.button :submit, class: "btn-warning", disable_with: t(".saving") %>
>     </div>   

我该如何解决?

感谢

1 个答案:

答案 0 :(得分:2)

确保表单的开头和表单的结尾包含提交按钮。并开始采用3.2使用disable_with

的方式
<%= simple_form_for(x) do |f| %>
    <%= f.button :submit, :value => "Submit", data: {"disable-with" => "Creating..."} %>
<% end %>