代码之家  ›  专栏  ›  技术社区  ›  iconoclast

如何以简单的形式设置内联标签的样式?

  •  0
  • iconoclast  · 技术社区  · 7 年前

    我有一个 Simple Form

    <%= 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!!!
    %>
    

    inline_label_html: {class: "inline_label_class"}
    

    既然Simple Form似乎不支持这个选项(至少在我期望的名称下,或者在我能找到的任何其他名称下),那么我如何实现相同的目标呢?

    1 回复  |  直到 7 年前
        1
  •  0
  •   Dende    7 年前

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

    然后你可以写一个包装器,它允许做这样的事情

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

    然后你的提示将被内联。

    请检查这里 https://github.com/plataformatec/simple_form/issues/1035

    推荐文章