ruby-on-rails - 如何在简单表单中设置内联标签的样式?
问题描述
我有一个简单表单复选框,它同时使用常规字段标签和内联标签:
<%= 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 似乎不支持此选项(至少以我期望的名称,也没有我能找到的任何其他名称),我怎样才能实现相同的目标?
解决方案
您可能想要一个提示,而不是内联标签。
然后你可以写一个包装器,它允许做这样的事情
<%= f.input :subdomain, input_wrapper_html: { class: 'col-sm-4' } %>
然后你的提示将是内联的。
请在此处查看https://github.com/plataformatec/simple_form/issues/1035
推荐阅读
- c# - .Net Core ControllerBase 动作方法 JSON 序列化设置
- javascript - 表单提交必填空白字段显示消息“请填写此字段。”
- azure-devops - 备用凭据尚未保存
- json - 使用 jq 从对象中获取 N 个值
- intellij-idea - Intellij:摆脱 iml 文件
- amazon-web-services - 在 AWS ECS 中使用 docker-compose.yml 和 ecs-params.yml 文件运行多个任务定义,具有不同的启动类型和卷挂载
- java - 是否有某种带有空闲 TTL 的锁/信号量
- typescript - 在打字稿中的基于 Vue 类的组件中键入 prop
- delphi - TWebBrowser:如何知道 OnNewWindow2 事件中的 URL?
- amazon-web-services - ELB 是否用于出站流量?