Rails simple_form 在必填字段的星形下给出了点,有更好的方法来删除它们吗?

发布于 2024-11-25 04:54:34 字数 294 浏览 2 评论 0原文

在我的许多项目中,我使用 simple_form 并且喜欢它。 然而,我发现一个非常奇怪的怪癖是,我在它为必填字段提供的 * 下面得到了 3 个小点。

我必须用以下方法来解决它:

= f.input :name, :label => '*', :required => false # Display purpose only (it is required)

这很混乱,因为该字段是必需的,所以这段代码看起来很难看。

对于看似常见的问题,是否有更好的解决方案?

In many of my projects I use simple_form and love it.
However one really strange quirk that I find is that I get 3 small dots underneath the * it supplies for required fields.

I have to get around it with:

= f.input :name, :label => '*', :required => false # Display purpose only (it is required)

Which is messy because the field is required, so this code looks ugly.

Is there a better fix for what seems like a common problem?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

伴我老 2024-12-02 04:54:34

我认为它来自 CSS,如果您使用蓝图,“abbraccronym”标签具有 border-bottom: 1px dotted black 样式。

尝试将下一行添加到您的 css 文件中:

abbr, accronym{ border-bottom: 0px; } /*try adding !important  after 0px if doesn't work*/

希望有帮助:)

I think it's from CSS, if you are useing blueprint, "abbr and accronym" tags have a border-bottom: 1px dotted black style.

Try add to your css file the next line :

abbr, accronym{ border-bottom: 0px; } /*try adding !important  after 0px if doesn't work*/

Wish helps :)

你与清晨阳光 2024-12-02 04:54:34

看起来像是 CSS 的东西。查看 CSS 上 abbr 标签的属性是什么。

It seems like CSS stuff. See what are the properties for abbr tags on your CSS.

十六岁半 2024-12-02 04:54:34

简单形式添加一个带有边框底部的缩写。
您可以仅使用 css 删除 border-bottom ,但您还需要覆盖文本下划线属性(我认为来自默认导航器样式)

因此,这个小 css 块应该可以工作:

  form abbr[title] {
    border-bottom: none !important;
    text-decoration: none !important;
  }

Simple form adds an abbr with a border-bottom.
You can remove the border-bottom just with css, but you also need to override the text underline property (which I think comes from default navigator styles)

So, this small css block should work :

  form abbr[title] {
    border-bottom: none !important;
    text-decoration: none !important;
  }
╰つ倒转 2024-12-02 04:54:34

我发现了另一个解决方案,以防其他人将来遇到这个问题。我回复了一个在 simple_form 上关闭的类似问题

我也遇到了这个问题,对于 simple_form 来说这会很容易
维护者会进行更改,因此可能值得研究。在非常
至少,如果其他人遇到问题,我想提供帮助
我正在使用的宝石组合。在新的 Rails 5.2.3 应用程序上,
bootstrap 4.3.1 和 simple form 4.1.0,我也遇到了同样的问题
星号下的省略号。

我找到了解决这个问题的方法,因为它实际上只在使用时发生
标签。在 locales/simple_form.en.yml 中,如果删除标记: '',并且
将 html: '
' 更改为 html: '*',这会删除出现在下面的“..”
星号。发生这种情况是因为有一个包含的样式
为任何缩写添加下划线虚线边框的引导程序
标签,允许用户选择该文本以查看
这个词的其余部分。

There's another solution that I found, in case anyone else comes across this question in the future. I responded to a similar issue that was closed on simple_form with this:

I had this issue too, and it would be pretty easy for the simple_form
maintainers to change, so it might be worth looking into. At the very
least, I'd like to help if someone else runs into the problem using
the gem combination I'm using. On a new rails 5.2.3 app, with
bootstrap 4.3.1 and simple form 4.1.0, I had the same issue with an
ellipses under the asterisk.

I found a way to solve it, since it actually only happens when using
the tag. In locales/simple_form.en.yml, if you remove mark: '', and
change html: '
' to html: '*', this removes the ".." that appears under
the asterisk. This occurs because there's an included style with
bootstrap that adds an underlined dotted border to any abbreviation
tags, which allow the user to select that text in order to view the
rest of the word.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文