1
0
Fork 0
mirror of https://github.com/heartcombo/simple_form.git synced 2022-11-09 12:19:26 -05:00

Merge pull request #1613 from gssbzn/color-field

Add color input
This commit is contained in:
Felipe Renan 2018-11-13 19:25:22 -02:00 committed by GitHub
commit 17e8a89e51
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 27 additions and 1 deletions

View file

@ -4,6 +4,7 @@
* Guess input type more carefully. [@sringling](https://github.com/sringling) * Guess input type more carefully. [@sringling](https://github.com/sringling)
* Allow custom error on forms without model. [@victorperez](https://github.com/victorperez) * Allow custom error on forms without model. [@victorperez](https://github.com/victorperez)
* Do not support Ruby < 2.3 anymore. [@gssbzn](https://github.com/gssbzn) * Do not support Ruby < 2.3 anymore. [@gssbzn](https://github.com/gssbzn)
* Add color inout type. [@gssbzn](https://github.com/gssbzn)
### Bug fix ### Bug fix
* Improve disabled option to input_field. [@betelgeuse](https://github.com/betelgeuse) * Improve disabled option to input_field. [@betelgeuse](https://github.com/betelgeuse)

View file

@ -10,6 +10,7 @@ module SimpleForm
autoload :CollectionInput autoload :CollectionInput
autoload :CollectionRadioButtonsInput autoload :CollectionRadioButtonsInput
autoload :CollectionSelectInput autoload :CollectionSelectInput
autoload :ColorInput
autoload :DateTimeInput autoload :DateTimeInput
autoload :FileInput autoload :FileInput
autoload :GroupedCollectionSelectInput autoload :GroupedCollectionSelectInput

View file

@ -0,0 +1,14 @@
# frozen_string_literal: true
module SimpleForm
module Inputs
class ColorInput < Base
def input(wrapper_options = nil)
input_html_options[:type] ||= "color" if html5?
merged_input_options = merge_wrapper_options(input_html_options, wrapper_options)
@builder.text_field(attribute_name, merged_input_options)
end
end
end
end

View file

@ -0,0 +1,10 @@
# frozen_string_literal: true
require 'test_helper'
class ColorInputTest < ActionView::TestCase
test 'input generates a color field' do
with_input_for @user, :favorite_color, :color
assert_select 'input[type=color].color#user_favorite_color'
end
end

View file

@ -91,7 +91,7 @@ class User
:post_count, :lock_version, :amount, :attempts, :action, :credit_card, :gender, :post_count, :lock_version, :amount, :attempts, :action, :credit_card, :gender,
:extra_special_company_id, :pictures, :picture_ids, :special_pictures, :extra_special_company_id, :pictures, :picture_ids, :special_pictures,
:special_picture_ids, :uuid, :friends, :friend_ids, :special_tags, :special_tag_ids, :special_picture_ids, :uuid, :friends, :friend_ids, :special_tags, :special_tag_ids,
:citext, :hstore, :json, :jsonb, :hourly :citext, :hstore, :json, :jsonb, :hourly, :favorite_color
def self.build(extra_attributes = {}) def self.build(extra_attributes = {})
attributes = { attributes = {