def date_picker(method, options = {})
      options = {
          class:            'form-control',
          read_only:        false,
          pre_calendar:     false,
          pre_label:        nil,
          post_calendar:    false,
          post_label:       false,
          attrib_val:       { },
          style:            { },
          input_group_size: ''
      }.merge(options)

      style = ''
      options[:style].each { |k,v| style += "#{k}: #{v};" }

      attrib = options[:attrib_val]
      attrib[:class] = options[:class]
      attrib[:style] = style
      attrib[:readonly] = 'readonly' if options[:read_only]

      if %w(sm small input-group-sm).include?(options[:input_group_size])
        options[:input_group_size] = 'input-group-sm'
      elsif %w(lg large input-group-lg).include?(options[:input_group_size])
        options[:input_group_size] = 'input-group-lg'
      else
        options[:input_group_size] = ''
      end

      attrib[:value] = object.send(method).strftime('%m/%d/%Y') if object.send(method)
      fld = text_field(method, attrib)

      # must have at least one attachment, default to post-calendar.
      options[:post_calendar] = true unless options[:pre_calendar] || options[:pre_label] || options[:post_label]

      # labels override calendars.
      options[:pre_calendar] = false if options[:pre_label]
      options[:post_calendar] = false if options[:post_label]

      # construct the prefix
      if options[:pre_calendar]
        pre = '<span class="input-group-addon"><i class="glyphicon glyphicon-calendar"></i></span>'
      elsif options[:pre_label]
        pre = "<span class=\"input-group-addon\">#{CGI::escape_html options[:pre_label]}</span>"
      else
        pre = ''
      end

      # construct the postfix
      if options[:post_calendar]
        post = '<span class="input-group-addon"><i class="glyphicon glyphicon-calendar"></i></span>'
      elsif options[:post_label]
        post = "<span class=\"input-group-addon\">#{CGI::escape_html options[:post_label]}</span>"
      else
        post = ''
      end

      # and then the return value.
      "<div class=\"input-group date #{options[:input_group_size]}\">#{pre}#{fld}#{post}</div>".html_safe
    end
def date_picker(method, options = {})
      options = {
          class:            'form-control',
          read_only:        false,
          pre_calendar:     false,
          pre_label:        nil,
          post_calendar:    false,
          post_label:       false,
          attrib_val:       { },
          style:            { },
          input_group_size: ''
      }.merge(options)

      style = ''
      options[:style].each { |k,v| style += "#{k}: #{v};" }

      attrib = options[:attrib_val]
      attrib[:class] = options[:class]
      attrib[:style] = style
      attrib[:readonly] = 'readonly' if options[:read_only]

      if %w(sm small input-group-sm).include?(options[:input_group_size])
        options[:input_group_size] = 'input-group-sm'
      elsif %w(lg large input-group-lg).include?(options[:input_group_size])
        options[:input_group_size] = 'input-group-lg'
      else
        options[:input_group_size] = ''
      end

      attrib[:value] = object.send(method).strftime('%m/%d/%Y') if object.send(method)
      fld = text_field(method, attrib)

      # must have at least one attachment, default to post-calendar.
      options[:post_calendar] = true unless options[:pre_calendar] || options[:pre_label] || options[:post_label]

      # labels override calendars.
      options[:pre_calendar] = false if options[:pre_label]
      options[:post_calendar] = false if options[:post_label]

      # construct the prefix
      if options[:pre_calendar]
        pre = '<span class="input-group-addon"><i class="glyphicon glyphicon-calendar"></i></span>'
      elsif options[:pre_label]
        pre = "<span class=\"input-group-addon\">#{CGI::escape_html options[:pre_label]}</span>"
      else
        pre = ''
      end

      # construct the postfix
      if options[:post_calendar]
        post = '<span class="input-group-addon"><i class="glyphicon glyphicon-calendar"></i></span>'
      elsif options[:post_label]
        post = "<span class=\"input-group-addon\">#{CGI::escape_html options[:post_label]}</span>"
      else
        post = ''
      end

      # and then the return value.
      "<div class=\"input-group date #{options[:input_group_size]}\">#{pre}#{fld}#{post}</div>".html_safe
    end
Creates a date picker selection field using a bootstrap input group.

 *Valid options:*

 input_group_size::
     Valid optional sizes are 'small' or 'large'.
 readonly::
     Set to true to make the input field read only.
 pre_calendar::
     Set to true to put a calendar icon before the input field.
 post_calendar::
     Set to true to put a calendar icon after the input field.  This is the default setting if no other pre/post
     is selected.
 pre_label::
     Set to a text value to put a label before the input field.  Replaces +pre_calendar+ if specified.
 post_label::
     Set to a text value to put a label after the input field.  Replaces +post_calendar+ if specified.

   f.date_picker :end_date, :pre_label => 'End'