Question

I have,

<%= semantic_form_for [:admin, @house, @note] do |f| %>

which gives me,

<form accept-charset="UTF-8" action="/admin/houses/10975/notes" class="formtastic note" id="new_note" method="post" novalidate="novalidate">

I want,

<form accept-charset="UTF-8" action="/admin/houses/10975/notes" class="formtastic note" id="new_note" method="post" novalidate="novalidate" data-persist = "garlic" >

Please take note of 'data-persist' attribute.

Is there any way to add such data-attribute to form tag through formtastic?

Était-ce utile?

La solution

semantic_form_for accepts the same options as form_for so for your problem, the solution would be

semantic_form_for [:admin, @house, @note], html: { data: { persist: 'garlic' } }

If for some reason, it is showing data=persistgarlic instead of what you expected, try the following

semantic_form_for [:admin, @house, @note], html: { 'data-persist' => 'garlic' }
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top