数字字段 Simple_form_for [英] Numeric field Simple_form_for

查看:38
本文介绍了数字字段 Simple_form_for的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我使用 Simple_form_for 时的数字字段中,使用 Google Chrome 时,滚动条显示在字段的一侧.

In my numeric fields when using Simple_form_for, scroll bars are showed on the side of the fields when using Google Chrome.

如何阻止它们显示?

推荐答案

看一些代码会有帮助,但是

它们不是滚动条;它们是向上和向下箭头按钮,用于增加/减少指定 step(默认为 1)的 number 输入字段.详细了解number输入类型

They're not scrollbars; they're up and down arrow buttons to increment/decrement the number input field the specified step (defaults to 1). Learn more about the number input type

默认情况下,模型的整数属性将使用 type="number" 作为字段使用 <代码>simple_form.

An integer attribute for your model by default will be rendered with type="number" as a field using simple_form.

要覆盖此行为,请使用 :as 选项指定字段的输入类型.

To override this behavior, specify the type of input for the field using the :as option.

<%= f.input :your_field_name, as: :string %>

(这记录在 README.md)

这篇关于数字字段 Simple_form_for的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆