Nielsen Rechia
Nielsen Rechia

Reputation: 649

Rails disable_with doesn't work in a form inside a modal

I'm with a problem with disable_with. I have a simple_form inside a modal and the disable_with doesn't work

but in a form_tag inside a modal it works well

here is my code

>  <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>   

How can I fix it?

thanks

Upvotes: 1

Views: 1224

Answers (1)

YaBoyQuy
YaBoyQuy

Reputation: 793

Make sure your start of the form and end of the form includes the submit button. And start resorting to the 3.2 way of using disable_with

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

Upvotes: 2

Related Questions