[英]Simple_form custom input
我有这行代码:
= f.input :goal, as: :select, input_html: {class: "select2"}, wrapper_html: {class: "form-fields"}
我想谈谈
= f.input :goal, as: :select2
在simple_form中使用自定义输入。 我该如何实现? 到目前为止,我有:
class Select2Input < SimpleForm::Inputs::StringInput
def input
input_html_options[:class]<< 'select2'
end
end
这应该使您半途而废:
class Select2Input < SimpleForm::Inputs::CollectionSelectInput
end
和
<%= f.input :email, as: :select2, wrapper_html:{class: "form-fields"} %>
您可能必须在config/initializers/simple_form.rb
为select2输入创建一个自定义包装,以便能够按照您真正想要的方式使用它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.