문제

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?

도움이 되었습니까?

해결책

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' }
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top