lib/globalize/rails/date_helper.rb
# Returns a select tag with options for each of the months January through December with the current month selected.
# The month names are presented as keys (what's shown to the user) and the month numbers (1-12) are used as values
# (what's submitted to the server). It's also possible to use month numbers for the presentation instead of names --
# set the <tt>:use_month_numbers</tt> key in +options+ to true for this to happen. If you want both numbers and names,
# set the <tt>:add_month_numbers</tt> key in +options+ to true. Examples:
#
#   select_month(Date.today)                             # Will use keys like "January", "March"
#   select_month(Date.today, :use_month_numbers => true) # Will use keys like "1", "3"
#   select_month(Date.today, :add_month_numbers => true) # Will use keys like "1 - January", "3 - March"
#
# Override the field name using the <tt>:field_name</tt> option, 'month' by default.
#
# If you would prefer to show month names as abbreviations, set the
# <tt>:use_short_month</tt> key in +options+ to true.
Returns a select tag with options for each of the months January through December with the current month selected.
The month names are presented as keys (what's shown to the user) and the month numbers (1-12) are used as values
(what's submitted to the server). It's also possible to use month numbers for the presentation instead of names
set the :use_month_numbers key in +options+ to true for this to happen. If you want both numbers and names,
set the :add_month_numbers key in +options+ to true. Examples.



Override the field name using the :field_name option, 'month' by default.

If you would prefer to show month names as abbreviations, set the
:use_short_month key in +options+ to true.
Returns a select tag with options for each of the months January through December with the current month selected . The month names are presented as keys ( what ' s shown to the user ) and the month numbers ( 1 - 12 ) are used as values ( what ' s submitted to the server ) . It ' s also possible to use month numbers for the presentation instead of names set the : use_month_numbers key in + options + to true for this to happen . If you want both numbers and names set the : add_month_numbers key in + options + to true . Examples . Override the field name using the : field_name option ' month ' by default . If you would prefer to show month names as abbreviations set the : use_short_month key in + options + to true .
def select_month(date, options = {}, html_options = {})
        val = date ? (date.kind_of?(Fixnum) ? date : date.month) : ''
        if options[:use_hidden]
          hidden_html(options[:field_name] || 'month', val, options)
        else
          month_options = []
          month_names = options[:use_month_names] || (options[:use_short_month] ? Date::ABBR_MONTHNAMES : Date::MONTHNAMES)
          abbr_key = options[:use_short_month] ? 'abbreviated month' : 'month'
          month_names.unshift(nil) if month_names.size < 13
          1.upto(12) do |month_number|
            month_name = if options[:use_month_numbers]
              month_number
            elsif options[:add_month_numbers]
              month_number.to_s + ' - ' + "#{month_names[month_number]} [#{abbr_key}]".t(month_names[month_number])
            else
              "#{month_names[month_number]} [#{abbr_key}]".t(month_names[month_number])
            end
            month_options << ((val == month_number) ?
              content_tag(:option, month_name, :value => month_number, :selected => "selected") :
              content_tag(:option, month_name, :value => month_number)
            )
            month_options << "\n"
          end
          select_html(options[:field_name] || 'month', month_options.join, options, html_options)
        end
      end
def select_month ( date , options = { } , html_options = { } ) val = date ? ( date . kind_of? ( Fixnum ) ? date : date . month ) : '' if options [ :use_hidden ] hidden_html ( options [ :field_name ] || 'month' , val , options ) else month_options = [ ] month_names = options [ :use_month_names ] || ( options [ :use_short_month ] ? Date :: ABBR_MONTHNAMES : Date :: MONTHNAMES ) abbr_key = options [ :use_short_month ] ? 'abbreviated month' : 'month' month_names . unshift ( nil ) if month_names . size < 13 1 . upto ( 12 ) do | month_number | month_name = if options [ :use_month_numbers ] month_number elsif options [ :add_month_numbers ] month_number . to_s + ' - ' + "#{month_names[month_number]} [#{abbr_key}]" . t ( month_names [ month_number ] ) else "#{month_names[month_number]} [#{abbr_key}]" . t ( month_names [ month_number ] ) end month_options << ( ( val == month_number ) ? content_tag ( :option , month_name , :value => month_number , :selected => "selected" ) : content_tag ( :option , month_name , :value => month_number ) ) month_options << "\n" end select_html ( options [ :field_name ] || 'month' , month_options . join , options , html_options ) end end
Returns a select tag with options for each of the months January through December with the current month selected.
Returns a select tag with options for each of the months January through December with the current month selected .
date
<not_specific>
options
<not_specific>
html_options
<not_specific>