vendredi 3 février 2017

Why is this Rails submit_tag disabling itself when I check a checkbox?

I'm running into a strange issue when trying to add a checkbox (for a boolean field) to my form(s). The forms works perfectly when just updating text fields or file fields but since I added in a boolean field checkbox, upon checking any of the checkboxes, the submit form button "disables" itself.

I can't seem to figure out how or where from Rails is doing this behind the scenes:

My code is as below:

<%= simple_form_for @resource, url: resources_path do |f| %>
<div class="form-items">

  <div class="form-item full">
    <%= f.input :name, autofocus: true %>
  </div> <!-- /.form-item full -->

  <div class="form-item">
    <%= f.input :file, as: :file %>
  </div> <!-- /.form-item -->

  <div class="form-item">
    <%= f.input :public_file %>
  </div> <!-- /.form-item -->

</div> <!-- /.form-items -->

<%= f.button :submit, 'Add Resource', class: 'button' %>
<% end %>

public_file is the boolean field which is marked as:

t.boolean  "public_file",       default: false

in the database schema

The submit button starts out with this rendered HTML

<input type="submit" name="commit" value="Add Resource" class="btn button" data-disable-with="Add Resource">

but as soon as I check the checkbox:

<input type="submit" name="commit" value="Add Resource" class="btn button" data-disable-with="Add Resource" disabled>

I'm not really too sure how to debug this and haven't found any documentation on Rails automatically disabling forms? Could that be what is happening?

Any pointers greatly received!




Aucun commentaire:

Enregistrer un commentaire