How to add data-attribute to the form tag in simple_form?

You can set data attributes directly by passing in a data hash, but all other HTML options must be wrapped in the HTML key. Example:

<%= form_for(@post, data: { validate: "parsley" }, html: { name: "go" }) do |f| %>
   ...
<% end %>

The HTML generated for this would be:

<form action='http://www.example.com' method='post' data-validate='parsley' name='go'>
  ...
 </form>

api.rubyonrails.org


Try this:

<%= simple_form_for @entity, :html => {:"data-validate" => 'parsley'} do |f| %>
    <!-- inputs -->
<% end %>

Update

From the comment below, to have the form include an HTML5 data attribute with no value try the following:

<%= simple_form_for @entity, :html => {:"other-data-value" => ''} do |f| %> 

By setting the attribute to an empty string the form helper renders just the attribute.