Created
January 17, 2015 09:37
-
-
Save prathamesh-sonpatki/49dfe395e4a8820cbb34 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ActionView | |
module Helpers | |
module Tags # :nodoc: | |
class Base # :nodoc: | |
def options_for_rendering(default_options) | |
default_options | |
end | |
end | |
class TextField < Base # :nodoc: | |
def render | |
tag("input", options_for_rendering(default_options_for_rendering)) | |
end | |
def default_options_for_rendering | |
options = @options.stringify_keys | |
options["size"] = options["maxlength"] unless options.key?("size") | |
options["type"] ||= field_type | |
options["value"] = options.fetch("value") { value_before_type_cast(object) } unless field_type == "file" | |
add_default_name_and_id(options) | |
options | |
end | |
end | |
end | |
end | |
end | |
class ActionView::Helpers::Tags::TextField | |
def options_for_rendering(default_options) | |
default_options["aria-labelledby"] = "label_#{default_options["id"]}" | |
default_options["aria-required"] = true | |
default_options | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment