lib/jqr-helpers/helpers.rb in jqr-helpers-1.0.3 vs lib/jqr-helpers/helpers.rb in jqr-helpers-1.0.4
- old
+ new
@@ -264,9 +264,25 @@
end
s + raw(s3)
end
end
+ # Create a date picker field. The attributes given are passed to
+ # text_field_tag. Note that Ruby and jQuery date formats are different.
+ # You will need to format the "value" parameter to match whatever format you
+ # are passing into the "options" parameter.
+ # @param name [String] the name of the form element.
+ # @param value [Date] the initial value.
+ # @param options [Hash] options to be passed to datepicker().
+ # @param html_options [Hash] options to be passed to text_field_tag.
+ # @return [String]
+ def date_picker_tag(name, value, options={}, html_options={})
+ html_options[:'data-date-options'] = options.to_json
+ html_options[:class] ||= ''
+ html_options[:class] << ' ujs-date-picker'
+ text_field_tag(name, value, html_options)
+ end
+
private
# Process options related to Ajax requests (e.g. button_to_ajax).
# @param options [Hash]
# @return [Hash] HTML options to inject.