Skip to content

Instantly share code, notes, and snippets.

@nacengineer
Last active August 29, 2015 13:56
Show Gist options
  • Save nacengineer/8944861 to your computer and use it in GitHub Desktop.
Save nacengineer/8944861 to your computer and use it in GitHub Desktop.
class DateTimePickerInput < SimpleForm::Inputs::Base
def input
template.content_tag(:div, class: 'input-group date form_datetime') do
template.concat @builder.text_field(attribute_name, input_html_options)
template.concat span_remove
template.concat span_table
end
end
private
def input_html_options
{class: 'form-control', readonly: true}
end
def span_remove
template.content_tag(:span, class: 'input-group-addon') do
template.concat icon_remove
end
end
def span_table
template.content_tag(:span, class: 'input-group-addon') do
template.concat icon_table
end
end
def icon_remove
"<i class='glyphicon glyphicon-remove'></i>".html_safe
end
def icon_table
"<i class='glyphicon glyphicon-th'></i>".html_safe
end
end
@nacengineer
Copy link
Author

add to simple form via app/inputs/date_time_picker_input.rb

call in simple form with as: :date_time_picker

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment