Skip to content

Instantly share code, notes, and snippets.

@dalpo
Created May 12, 2013 13:42
Show Gist options
  • Save dalpo/5563600 to your computer and use it in GitHub Desktop.
Save dalpo/5563600 to your computer and use it in GitHub Desktop.
Simple_form custom input for bootstrap-datepicker
module SimpleForm
module Inputs
class DatePickerInput < SimpleForm::Inputs::StringInput
def input_html_options
value = object.send(attribute_name)
options = {
value: value.nil?? nil : I18n.localize(value, format: :datepicker),
data: {
behaviour: 'datepicker'
}
}
# add all html option you need...
super.merge options
end
def input_html_classes
super.push('datepicker')
end
def input
"#{super} #{template.content_tag(:span, template.glyph(:calendar), class: 'add-on')}".html_safe
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment