Give form a CSS class using simple_form_for

2020-02-23 05:47发布

Here's what I've tried, and the simple_form_for call ignored my class setting.

# Rails code in view:
<%= simple_form_for @admin_artist, :class => 'foobarbaz' do |f| %>

# Renders:
<form accept-charset="UTF-8" action="/admin/artists" class="simple_form new_admin_artist" id="new_admin_artist" method="post" novalidate="novalidate">

Any suggestions?

2条回答
Juvenile、少年°
2楼-- · 2020-02-23 06:21

this would work

<%= simple_form_for @admin_artist, :html=> { class: 'foobarbaz' } do |f| %>
查看更多
闹够了就滚
3楼-- · 2020-02-23 06:43

You should use :html like this:

<%= simple_form_for @admin_artist, :html => { role: 'form', class: 'foobarbaz' } do |f| %>
查看更多
登录 后发表回答