Sha256: 6ff84aa9aaacbbfa901d878297db478856071509ad2e84ef8ae9fbba623fee04

Contents?: true

Size: 583 Bytes

Versions: 25

Compression:

Stored size: 583 Bytes

Contents

module ActionView
  module Helpers
    module Tags # :nodoc:
      class ColorField < TextField # :nodoc:
        def render
          options = @options.stringify_keys
          options["value"] = options.fetch("value") { validate_color_string(value(object)) }
          @options = options
          super
        end

        private

          def validate_color_string(string)
            regex = /#[0-9a-fA-F]{6}/
            if regex.match(string)
              string.downcase
            else
              "#000000"
            end
          end
      end
    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
actionpack-4.0.13 lib/action_view/helpers/tags/color_field.rb
actionpack-4.0.13.rc1 lib/action_view/helpers/tags/color_field.rb
actionpack-4.0.11.1 lib/action_view/helpers/tags/color_field.rb
actionpack-4.0.12 lib/action_view/helpers/tags/color_field.rb
actionpack-4.0.11 lib/action_view/helpers/tags/color_field.rb
actionpack-4.0.10 lib/action_view/helpers/tags/color_field.rb
actionpack-4.0.10.rc2 lib/action_view/helpers/tags/color_field.rb
actionpack-4.0.10.rc1 lib/action_view/helpers/tags/color_field.rb
actionpack-4.0.9 lib/action_view/helpers/tags/color_field.rb
actionpack-4.0.8 lib/action_view/helpers/tags/color_field.rb
actionpack-4.0.7 lib/action_view/helpers/tags/color_field.rb
actionpack-4.0.6 lib/action_view/helpers/tags/color_field.rb
actionpack-4.0.6.rc3 lib/action_view/helpers/tags/color_field.rb
actionpack-4.0.6.rc2 lib/action_view/helpers/tags/color_field.rb
actionpack-4.0.6.rc1 lib/action_view/helpers/tags/color_field.rb
actionpack-4.0.5 lib/action_view/helpers/tags/color_field.rb
actionpack-4.0.4 lib/action_view/helpers/tags/color_field.rb
actionpack-4.0.4.rc1 lib/action_view/helpers/tags/color_field.rb
actionpack-4.0.3 lib/action_view/helpers/tags/color_field.rb
actionpack-4.0.2 lib/action_view/helpers/tags/color_field.rb