Created
January 29, 2015 21:41
-
-
Save dimroc/d169bed0afae7b7d9610 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| # Could not call this DatepickerInput because it leads to | |
| # the setting of css classes that cause chaos in the javascript/css | |
| # side of things. | |
| class BetterDateInput < SimpleForm::Inputs::StringInput | |
| def input(wrapper_options = nil) | |
| input_html_classes.unshift(:datepicker) | |
| input_html_options[:autocomplete] = 'off' | |
| value = @builder.object.send(attribute_name) | |
| input_html_options[:value] = case value | |
| when Date, Time, DateTime | |
| format = options[:format] || :calendar | |
| l(value, format: format) | |
| else | |
| value.to_s | |
| end | |
| merged_input_options = merge_wrapper_options(input_html_options, wrapper_options) | |
| @builder.text_field(attribute_name, merged_input_options) | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment