type="number" 到 type="text" 并在 ActiveAdmin 中添加 class(全局)
type="number" to type="text" and add class in ActiveAdmin (globally)
我的表中的字段类型为 numeric(12,2)
。
ActiveAdmin(在 formastic gem 的帮助下)将它们呈现为 type="number"
。
我希望它将它们呈现为 type="text"
并添加 class float-field
。是否有可能在全球范围内进行?我不反对猴子修补它。
Active Admin 建立在 Formtastic 之上。 Fomtastic 自述文件 Modified & Custom Inputs。您将实施 apps/inputs/float_input 并将其引用为 f.input :total, as: :float
我决定使用 monkeypatch Formastic gem:
module Formtastic
module Inputs
class NumberInput
include Base
include Base::Stringish
include Base::Placeholder
def to_html
input_wrapping do
label_html << builder.text_field(method, input_html_options.merge(class: 'float-field'))
end
end
end
end
end
我的表中的字段类型为 numeric(12,2)
。
ActiveAdmin(在 formastic gem 的帮助下)将它们呈现为 type="number"
。
我希望它将它们呈现为 type="text"
并添加 class float-field
。是否有可能在全球范围内进行?我不反对猴子修补它。
Active Admin 建立在 Formtastic 之上。 Fomtastic 自述文件 Modified & Custom Inputs。您将实施 apps/inputs/float_input 并将其引用为 f.input :total, as: :float
我决定使用 monkeypatch Formastic gem:
module Formtastic
module Inputs
class NumberInput
include Base
include Base::Stringish
include Base::Placeholder
def to_html
input_wrapping do
label_html << builder.text_field(method, input_html_options.merge(class: 'float-field'))
end
end
end
end
end