aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view/helpers/date_helper.rb
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2005-09-11 05:58:00 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2005-09-11 05:58:00 +0000
commitb62243a5cc957ae0c7380bf8e020219e45366fe2 (patch)
tree3e7ee6bf56652637f4ac84f08f360ca729ef5b0f /actionpack/lib/action_view/helpers/date_helper.rb
parentda7ba91d8666770c6288f8d25cd501fd227b0413 (diff)
downloadrails-b62243a5cc957ae0c7380bf8e020219e45366fe2.tar.gz
rails-b62243a5cc957ae0c7380bf8e020219e45366fe2.tar.bz2
rails-b62243a5cc957ae0c7380bf8e020219e45366fe2.zip
Added :disabled option to all data selects that'll make the elements inaccessible for change #2167, #253 [eigentone]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2184 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib/action_view/helpers/date_helper.rb')
-rwxr-xr-xactionpack/lib/action_view/helpers/date_helper.rb20
1 files changed, 12 insertions, 8 deletions
diff --git a/actionpack/lib/action_view/helpers/date_helper.rb b/actionpack/lib/action_view/helpers/date_helper.rb
index a516072acb..6323006bd0 100755
--- a/actionpack/lib/action_view/helpers/date_helper.rb
+++ b/actionpack/lib/action_view/helpers/date_helper.rb
@@ -62,6 +62,8 @@ module ActionView
# set the order of the tags using the <tt>:order</tt> option with an array of symbols <tt>:year</tt>, <tt>:month</tt> and <tt>:day</tt> in
# the desired order. Symbols may be omitted and the respective select is not included.
#
+ # Passing :disabled => true as part of the +options+ will make elements inaccessible for change.
+ #
# NOTE: Discarded selects will default to 1. So if no month select is available, January will be assumed.
#
# Examples:
@@ -118,7 +120,7 @@ module ActionView
)
end
- select_html(options[:field_name] || 'second', second_options, options[:prefix], options[:include_blank], options[:discard_type])
+ select_html(options[:field_name] || 'second', second_options, options[:prefix], options[:include_blank], options[:discard_type], options[:disabled])
end
# Returns a select tag with options for each of the minutes 0 through 59 with the current minute selected.
@@ -135,7 +137,7 @@ module ActionView
)
end
- select_html(options[:field_name] || 'minute', minute_options, options[:prefix], options[:include_blank], options[:discard_type])
+ select_html(options[:field_name] || 'minute', minute_options, options[:prefix], options[:include_blank], options[:discard_type], options[:disabled])
end
# Returns a select tag with options for each of the hours 0 through 23 with the current hour selected.
@@ -151,7 +153,7 @@ module ActionView
)
end
- select_html(options[:field_name] || 'hour', hour_options, options[:prefix], options[:include_blank], options[:discard_type])
+ select_html(options[:field_name] || 'hour', hour_options, options[:prefix], options[:include_blank], options[:discard_type], options[:disabled])
end
# Returns a select tag with options for each of the days 1 through 31 with the current day selected.
@@ -167,7 +169,7 @@ module ActionView
)
end
- select_html(options[:field_name] || 'day', day_options, options[:prefix], options[:include_blank], options[:discard_type])
+ select_html(options[:field_name] || 'day', day_options, options[:prefix], options[:include_blank], options[:discard_type], options[:disabled])
end
# Returns a select tag with options for each of the months January through December with the current month selected.
@@ -203,7 +205,7 @@ module ActionView
)
end
- select_html(options[:field_name] || 'month', month_options, options[:prefix], options[:include_blank], options[:discard_type])
+ select_html(options[:field_name] || 'month', month_options, options[:prefix], options[:include_blank], options[:discard_type], options[:disabled])
end
# Returns a select tag with options for each of the five years on each side of the current, which is selected. The five year radius
@@ -229,14 +231,16 @@ module ActionView
)
end
- select_html(options[:field_name] || 'year', year_options, options[:prefix], options[:include_blank], options[:discard_type])
+ select_html(options[:field_name] || 'year', year_options, options[:prefix], options[:include_blank], options[:discard_type], options[:disabled])
end
private
- def select_html(type, options, prefix = nil, include_blank = false, discard_type = false)
+ def select_html(type, options, prefix = nil, include_blank = false, discard_type = false, disabled = false)
select_html = %(<select name="#{prefix || DEFAULT_PREFIX})
select_html << "[#{type}]" unless discard_type
- select_html << %(">\n)
+ select_html << %(")
+ select_html << %( disabled="disabled") if disabled
+ select_html << %(>\n)
select_html << %(<option value=""></option>\n) if include_blank
select_html << options.to_s
select_html << "</select>\n"