mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
generate HTML5 number_field tag for integer fields
This commit is contained in:
parent
12a4376ae9
commit
4d1752bfb2
2 changed files with 12 additions and 7 deletions
|
@ -13,12 +13,13 @@ module Rails
|
|||
|
||||
def field_type
|
||||
@field_type ||= case type
|
||||
when :integer, :float, :decimal then :text_field
|
||||
when :time then :time_select
|
||||
when :datetime, :timestamp then :datetime_select
|
||||
when :date then :date_select
|
||||
when :text then :text_area
|
||||
when :boolean then :check_box
|
||||
when :integer then :number_field
|
||||
when :float, :decimal then :text_field
|
||||
when :time then :time_select
|
||||
when :datetime, :timestamp then :datetime_select
|
||||
when :date then :date_select
|
||||
when :text then :text_area
|
||||
when :boolean then :check_box
|
||||
else
|
||||
:text_field
|
||||
end
|
||||
|
|
|
@ -4,8 +4,12 @@ require 'rails/generators/generated_attribute'
|
|||
class GeneratedAttributeTest < Rails::Generators::TestCase
|
||||
include GeneratorsTestHelper
|
||||
|
||||
def test_field_type_returns_number_field
|
||||
assert_field_type :integer, :number_field
|
||||
end
|
||||
|
||||
def test_field_type_returns_text_field
|
||||
%w(integer float decimal string).each do |attribute_type|
|
||||
%w(float decimal string).each do |attribute_type|
|
||||
assert_field_type attribute_type, :text_field
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue