def date_picker_field(f, method, options = {})
      options = {
          class:            'form-control',
          read_only:        false,
          pre_calendar:     false,
          pre_label:        nil,
          post_calendar:    true,
          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 options[:input_group_size] == 'sm' || options[:input_group_size] == 'small' || options[:input_group_size] == 'input-group-sm'
        options[:input_group_size] = 'input-group-sm'
      elsif options[:input_group_size] == 'lg' || options[:input_group_size] == 'large' || options[:input_group_size] == 'input-group-lg'
        options[:input_group_size] = 'input-group-lg'
      else
        options[:input_group_size] = ''
      end


      attrib[:value] = f.object.send(method).to_s(:date4) if f.object.send(method)
      fld = f.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\">#{h 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\">#{h 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_field(f, method, options = {})
      options = {
          class:            'form-control',
          read_only:        false,
          pre_calendar:     false,
          pre_label:        nil,
          post_calendar:    true,
          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 options[:input_group_size] == 'sm' || options[:input_group_size] == 'small' || options[:input_group_size] == 'input-group-sm'
        options[:input_group_size] = 'input-group-sm'
      elsif options[:input_group_size] == 'lg' || options[:input_group_size] == 'large' || options[:input_group_size] == 'input-group-lg'
        options[:input_group_size] = 'input-group-lg'
      else
        options[:input_group_size] = ''
      end


      attrib[:value] = f.object.send(method).to_s(:date4) if f.object.send(method)
      fld = f.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\">#{h 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\">#{h 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.
 *   +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.