【问题标题】:how to remove asterisk in required fields when using simple form?使用简单表单时如何删除必填字段中的星号?
【发布时间】:2018-10-14 11:42:01
【问题描述】:

在 simple_form 初始化器中有这一行

  # How the label text should be generated altogether with the required text.
  # config.label_text = lambda { |label, required, explicit_label| "#{required} #{label}" }

我删除了评论并将其更改为

  # How the label text should be generated altogether with the required text.
   config.label_text = lambda { |label, required, explicit_label| "#{label}" }

但这不会影响必填字段中的星号。 * 仍然存在于标签中。如何删除必填字段中的星号?

更新:

我正在上传图片。即使在服务器重新启动后,askterisk 仍然存在。

【问题讨论】:

  • 在此之后您是否重新启动了服务器?
  • @Gabbar 是的,服务器重启后星号仍然存在。

标签: ruby-on-rails simple-form


【解决方案1】:

好的,所以我忘记了在生成简单表单时我使用了引导标志。这创建了第二个初始化文件 simple_form_bootstrap.rb。所以必须在这个文件中进行更改。更改此文件后,它正在工作。

【讨论】:

  • 宾果游戏。这对我来说也正是如此。
【解决方案2】:

我相信一个 hacky 解决方法是通过 css 来完成:

abbr[title="required"] {
  display: none;
}

用选择*的任何选择器替换缩写

【讨论】:

    猜你喜欢
    • 2016-05-29
    • 1970-01-01
    • 2010-11-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-10-03
    • 1970-01-01
    • 2015-02-09
    相关资源
    最近更新 更多