如何在简单表单中设置内联标签的样式?

时间:2018-07-03 01:34:23

标签: ruby-on-rails ruby simple-form

我有一个Simple Form复选框,它同时使用常规字段标签和内联标签:

SELECT col1, col2 FROM table where rownum<=45000 AND \$CONDITIONS

并且我需要向内联标签添加样式。我怎样才能做到这一点?我希望遵循这种模式的某些东西能够正常工作:

<%= f.input :remove_default_template, 
  label: 'Advanced Option',
  inline_label: "Remove Header, Footer, and Department Name"
%>

但最后一行不起作用:

<%= f.input :remove_default_template, 
  label: 'Advanced Option',
  inline_label: "Remove Header, Footer, and Department Name",
  inline_label_html: 
  input_html: {class: "input_class"},               # THIS works
  wrapper_html: {class: "wrapper_class"},           # THIS works
  label_html: {class: "label_class"},               # THIS works  
  inline_label_html: {class: "inline_label_class"}  # THIS DOES NOT WORK!!!
%>

由于“简单表单”似乎不支持此选项(至少以我期望的名称,或者我可以找到的其他任何名称),如何实现相同的目标?

1 个答案:

答案 0 :(得分:0)

您可能需要提示而不是内联标签。

然后您可以编写一个包装器,该包装器可以执行类似的操作

<%= f.input :subdomain, input_wrapper_html: { class: 'col-sm-4' } %>

然后您的提示将内联。

请在此处查看https://github.com/plataformatec/simple_form/issues/1035