如何在simple_form 2中的包装器中向输入组件添加类 [英] how to add a class to the input component in a wrapper in simple_form 2
本文介绍了如何在simple_form 2中的包装器中向输入组件添加类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我在 simple_form 2.0.0.rc 中使用名为 :hinted 的自定义包装器时,我试图在我的输入字段中包含 class="text"
I am trying to have class="text"
in my input fields when using a custom wrapper called :hinted in simple_form 2.0.0.rc
config.wrappers :hinted do |b|
b.use :input, :class => "text"
end
但是输出没有那个类,我试过
but the output doesn't have that class, I tried
:wrap_with => {:class => 'text'}
没用
有人知道这是怎么做的吗?
Does anyone know how this is done?
谢谢!
推荐答案
目前没有办法做到这一点.如果需要,您可以像这样使用 defaults
选项.
Currently there no way to do this. You can use the defaults
options like this if you want.
<%= simple_form_for(@user, :defaults => { :input_html => { :class => "text" } }) do %>
<%= f.input :name %>
<% end %>
这篇关于如何在simple_form 2中的包装器中向输入组件添加类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文