public
Fork of rails/rails
Description: Ruby on Rails
Homepage: http://rubyonrails.org
Clone URL: git://github.com/ddollar/rails.git
Search Repo:
Fixed that form helpers would treat string and symbol keys differently in 
html_options (and possibly create duplicate entries) #112 [bitsweat]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@833 
5ecf4fe2-1ee6-0310-87b1-e25e094e27de
dhh (author)
Sun Mar 06 03:50:41 -0800 2005
commit  dfac1cea3d851000116a23ab14c2b1ae981f7a12
tree    91abe3727d19f4c13affe1a2e4bc4637b35d5fdf
parent  db41d2dd5c738ca44a07330cf02e9d817fedc34c
...
1
2
 
 
3
4
5
...
1
2
3
4
5
6
7
0
@@ -1,5 +1,7 @@
0
 *SVN*
0
 
0
+* Fixed that form helpers would treat string and symbol keys differently in html_options (and possibly create duplicate entries) #112 [bitsweat]
0
+
0
 * Fixed that broken pipe errors (clients disconnecting in mid-request) could bring down a fcgi process
0
 
0
 * Added the original exception message to session recall errors (so you can see which class wasnt required)
...
15
16
17
18
 
19
20
21
...
41
42
43
44
 
45
46
47
...
56
57
58
59
60
 
 
 
61
62
63
 
64
65
66
 
67
68
 
69
70
71
...
73
74
75
76
 
77
78
79
...
86
87
88
89
 
90
91
92
93
94
95
96
 
 
97
98
99
100
101
 
102
103
104
...
107
108
109
110
 
111
112
113
...
116
117
118
119
 
120
121
122
...
15
16
17
 
18
19
20
21
...
41
42
43
 
44
45
46
47
...
56
57
58
 
 
59
60
61
62
63
 
64
65
66
 
67
68
 
69
70
71
72
...
74
75
76
 
77
78
79
80
...
87
88
89
 
90
91
92
93
94
95
96
 
97
98
99
100
101
102
 
103
104
105
106
...
109
110
111
 
112
113
114
115
...
118
119
120
 
121
122
123
124
0
@@ -15,7 +15,7 @@ module ActionView
0
     module ActiveRecordHelper
0
       # Returns a default input tag for the type of object returned by the method. Example
0
       # (title is a VARCHAR column and holds "Hello World"):
0
- # input("post", "title") =>
0
+ # input("post", "title") =>
0
       # <input id="post_title" name="post[title]" size="30" type="text" value="Hello World" />
0
       def input(record_name, method)
0
         InstanceTag.new(record_name, method, self).to_tag
0
@@ -41,7 +41,7 @@ module ActionView
0
       # It's possible to specialize the form builder by using a different action name and by supplying another
0
       # block renderer. Example (entry is a new record that has a message attribute using VARCHAR):
0
       #
0
- # form("entry", :action => "sign", :input_block =>
0
+ # form("entry", :action => "sign", :input_block =>
0
       # Proc.new { |record, column| "#{column.human_name}: #{input(record, column.name)}<br />" }) =>
0
       #
0
       # <form action='/post/sign' method='post'>
0
@@ -56,16 +56,17 @@ module ActionView
0
       # form << content_tag("b", "Department")
0
       # form << collection_select("department", "id", @departments, "id", "name")
0
       # end
0
- def form(record_name, options = {})
0
- record = instance_eval("@#{record_name}")
0
+ def form(record_name, options = nil)
0
+ options = (options || {}).symbolize_keys
0
+ record = instance_eval("@#{record_name}")
0
 
0
         options[:action] ||= record.new_record? ? "create" : "update"
0
- action = url_for(:action => options[:action])
0
+ action = url_for(:action => options[:action])
0
 
0
         submit_value = options[:submit_value] || options[:action].gsub(/[^\w]/, '').capitalize
0
-
0
+
0
         id_field = record.new_record? ? "" : InstanceTag.new(record_name, "id", self).to_input_field_tag("hidden")
0
-
0
+
0
         formtag = %(<form action="#{action}" method="post">#{id_field}) + all_input_tags(record, record_name, options)
0
         yield formtag if block_given?
0
         formtag + %(<input type="submit" value="#{submit_value}" /></form>)
0
@@ -73,7 +74,7 @@ module ActionView
0
 
0
       # Returns a string containing the error message attached to the +method+ on the +object+, if one exists.
0
       # This error message is wrapped in a DIV tag, which can be specialized to include both a +prepend_text+ and +append_text+
0
- # to properly introduce the error and a +css_class+ to style it accordingly. Examples (post has an error message
0
+ # to properly introduce the error and a +css_class+ to style it accordingly. Examples (post has an error message
0
       # "can't be empty" on the title attribute):
0
       #
0
       # <%= error_message_on "post", "title" %> =>
0
@@ -86,19 +87,20 @@ module ActionView
0
           "<div class=\"#{css_class}\">#{prepend_text + (errors.is_a?(Array) ? errors.first : errors) + append_text}</div>"
0
         end
0
       end
0
-
0
+
0
       # Returns a string with a div containing all the error messages for the object located as an instance variable by the name
0
       # of <tt>object_name</tt>. This div can be tailored by the following options:
0
       #
0
       # * <tt>header_tag</tt> - Used for the header of the error div (default: h2)
0
       # * <tt>id</tt> - The id of the error div (default: errorExplanation)
0
       # * <tt>class</tt> - The class of the error div (default: errorExplanation)
0
- def error_messages_for(object_name, options={})
0
+ def error_messages_for(object_name, options = {})
0
+ options = options.symbolize_keys
0
         object = instance_eval "@#{object_name}"
0
         unless object.errors.empty?
0
           content_tag("div",
0
             content_tag(
0
- options[:header_tag] || "h2",
0
+ options[:header_tag] || "h2",
0
               "#{pluralize(object.errors.count, "error")} prohibited this #{object_name.gsub("_", " ")} from being saved"
0
             ) +
0
             content_tag("p", "There were problems with the following fields:") +
0
@@ -107,7 +109,7 @@ module ActionView
0
           )
0
         end
0
       end
0
-
0
+
0
       private
0
         def all_input_tags(record, record_name, options)
0
           input_block = options[:input_block] || default_input_block
0
@@ -116,7 +118,7 @@ module ActionView
0
 
0
         def default_input_block
0
           Proc.new { |record, column| "<p><label for=\"#{record}_#{column.name}\">#{column.human_name}</label><br />#{input(record, column.name)}</p>" }
0
- end
0
+ end
0
     end
0
 
0
     class InstanceTag #:nodoc:
...
10
11
12
13
 
14
15
 
16
17
 
18
19
20
21
 
22
23
24
...
38
39
40
41
 
42
43
44
...
48
49
50
51
 
52
53
54
...
10
11
12
 
13
14
 
15
16
 
17
18
19
20
 
21
22
23
24
...
38
39
40
 
41
42
43
44
...
48
49
50
 
51
52
53
54
0
@@ -10,15 +10,15 @@ module ActionView
0
       # either be <tt>:rss</tt> (default) or <tt>:atom</tt> and the +options+ follow the url_for style of declaring a link target.
0
       #
0
       # Examples:
0
- # auto_discovery_link_tag # =>
0
+ # auto_discovery_link_tag # =>
0
       # <link rel="alternate" type="application/rss+xml" title="RSS" href="http://www.curenthost.com/controller/action" />
0
- # auto_discovery_link_tag(:atom) # =>
0
+ # auto_discovery_link_tag(:atom) # =>
0
       # <link rel="alternate" type="application/atom+xml" title="ATOM" href="http://www.curenthost.com/controller/action" />
0
- # auto_discovery_link_tag(:rss, :action => "feed") # =>
0
+ # auto_discovery_link_tag(:rss, :action => "feed") # =>
0
       # <link rel="alternate" type="application/atom+xml" title="ATOM" href="http://www.curenthost.com/controller/feed" />
0
       def auto_discovery_link_tag(type = :rss, options = {})
0
         tag(
0
- "link", "rel" => "alternate", "type" => "application/#{type}+xml", "title" => type.to_s.upcase,
0
+ "link", "rel" => "alternate", "type" => "application/#{type}+xml", "title" => type.to_s.upcase,
0
           "href" => url_for(options.merge(:only_path => false))
0
         )
0
       end
0
@@ -38,7 +38,7 @@ module ActionView
0
           content_tag("script", "", "language" => "JavaScript", "type" => "text/javascript", "src" => source)
0
         }.join("\n")
0
       end
0
-
0
+
0
       # Returns a css link tag per source given as argument. Examples:
0
       #
0
       # stylesheet_link_tag "style" # =>
0
@@ -48,7 +48,7 @@ module ActionView
0
       # <link href="/stylesheets/random.styles" media="screen" rel="Stylesheet" type="text/css" />
0
       # <link href="/css/stylish.css" media="screen" rel="Stylesheet" type="text/css" />
0
       def stylesheet_link_tag(*sources)
0
- sources.collect { |source|
0
+ sources.collect { |source|
0
           source = "/stylesheets/#{source}" unless source.include?("/")
0
           source = "#{source}.css" unless source.include?(".")
0
           tag("link", "rel" => "Stylesheet", "type" => "text/css", "media" => "screen", "href" => source)
...
5
6
7
8
 
9
10
11
...
13
14
15
16
 
17
18
19
20
 
21
22
23
...
28
29
30
31
 
32
33
34
...
48
49
50
51
 
52
53
54
...
107
108
109
110
 
111
112
113
...
122
123
124
125
 
126
127
128
...
137
138
139
140
 
141
142
143
144
145
146
147
 
148
149
150
151
 
152
153
154
...
158
159
160
161
 
162
163
164
...
167
168
169
170
 
171
172
173
174
175
176
177
 
178
179
 
180
181
182
...
187
188
189
190
 
191
192
193
194
195
196
197
 
198
199
200
...
206
207
208
209
 
210
211
212
...
217
218
219
220
221
 
 
222
223
224
 
225
226
227
228
229
 
230
231
232
233
234
 
235
236
237
238
239
240
241
 
242
243
244
245
 
 
246
247
248
...
250
251
252
253
 
254
255
256
...
5
6
7
 
8
9
10
11
...
13
14
15
 
16
17
18
19
 
20
21
22
23
...
28
29
30
 
31
32
33
34
...
48
49
50
 
51
52
53
54
...
107
108
109
 
110
111
112
113
...
122
123
124
 
125
126
127
128
...
137
138
139
 
140
141
142
143
144
145
146
 
147
148
149
150
 
151
152
153
154
...
158
159
160
 
161
162
163
164
...
167
168
169
 
170
171
172
173
174
175
176
 
177
178
 
179
180
181
182
...
187
188
189
 
190
191
192
193
194
195
196
 
197
198
199
200
...
206
207
208
 
209
210
211
212
...
217
218
219
 
 
220
221
222
223
 
224
225
226
227
228
 
229
230
231
232
233
 
234
235
236
237
238
239
240
 
241
242
243
 
 
244
245
246
247
248
...
250
251
252
 
253
254
255
256
0
@@ -5,7 +5,7 @@ module ActionView
0
     # The Date Helper primarily creates select/option tags for different kinds of dates and date elements. All of the select-type methods
0
     # share a number of common options that are as follows:
0
     #
0
- # * <tt>:prefix</tt> - overwrites the default prefix of "date" used for the select names. So specifying "birthday" would give
0
+ # * <tt>:prefix</tt> - overwrites the default prefix of "date" used for the select names. So specifying "birthday" would give
0
     # birthday[month] instead of date[month] if passed to the select_month method.
0
     # * <tt>:include_blank</tt> - set to true if it should be possible to set an empty date.
0
     # * <tt>:discard_type</tt> - set to true if you want to discard the type part of the select name. If set to true, the select_month
0
@@ -13,11 +13,11 @@ module ActionView
0
     module DateHelper
0
       DEFAULT_PREFIX = "date" unless const_defined?("DEFAULT_PREFIX")
0
 
0
- # Reports the approximate distance in time between to Time objects. For example, if the distance is 47 minutes, it'll return
0
+ # Reports the approximate distance in time between to Time objects. For example, if the distance is 47 minutes, it'll return
0
       # "about 1 hour". See the source for the complete wording list.
0
       def distance_of_time_in_words(from_time, to_time)
0
         distance_in_minutes = ((to_time - from_time) / 60).round
0
-
0
+
0
         case distance_in_minutes
0
           when 0 then "less than a minute"
0
           when 1 then "1 minute"
0
@@ -28,7 +28,7 @@ module ActionView
0
           else "#{(distance_in_minutes / 1440).round} days"
0
         end
0
       end
0
-
0
+
0
       # Like distance_of_time_in_words, but where <tt>to_time</tt> is fixed to <tt>Time.now</tt>.
0
       def distance_of_time_in_words_to_now(from_time)
0
         distance_of_time_in_words(from_time, Time.now)
0
@@ -48,7 +48,7 @@ module ActionView
0
       #
0
       # date_select("post", "written_on")
0
       # date_select("post", "written_on", :start_year => 1995)
0
- # date_select("post", "written_on", :start_year => 1995, :use_month_numbers => true,
0
+ # date_select("post", "written_on", :start_year => 1995, :use_month_numbers => true,
0
       # :discard_day => true, :include_blank => true)
0
       # date_select("post", "written_on", :order => [:day, :month, :year])
0
       # date_select("user", "birthday", :order => [:month, :day])
0
@@ -107,7 +107,7 @@ module ActionView
0
 
0
         0.upto(59) do |minute|
0
           minute_options << ((datetime.kind_of?(Fixnum) ? datetime : datetime.min) == minute ?
0
- "<option selected=\"selected\">#{leading_zero_on_single_digits(minute)}</option>\n" :
0
+ "<option selected=\"selected\">#{leading_zero_on_single_digits(minute)}</option>\n" :
0
             "<option>#{leading_zero_on_single_digits(minute)}</option>\n"
0
           )
0
         end
0
@@ -122,7 +122,7 @@ module ActionView
0
 
0
         0.upto(23) do |hour|
0
           hour_options << ((datetime.kind_of?(Fixnum) ? datetime : datetime.hour) == hour ?
0
- "<option selected=\"selected\">#{leading_zero_on_single_digits(hour)}</option>\n" :
0
+ "<option selected=\"selected\">#{leading_zero_on_single_digits(hour)}</option>\n" :
0
             "<option>#{leading_zero_on_single_digits(hour)}</option>\n"
0
           )
0
         end
0
@@ -137,18 +137,18 @@ module ActionView
0
 
0
         1.upto(31) do |day|
0
           day_options << ((date.kind_of?(Fixnum) ? date : date.day) == day ?
0
- "<option selected=\"selected\">#{day}</option>\n" :
0
+ "<option selected=\"selected\">#{day}</option>\n" :
0
             "<option>#{day}</option>\n"
0
           )
0
         end
0
 
0
         select_html("day", day_options, options[:prefix], options[:include_blank], options[:discard_type])
0
       end
0
-
0
+
0
       # Returns a select tag with options for each of the months January through December with the current month selected.
0
       # The month names are presented as keys (what's shown to the user) and the month numbers (1-12) are used as values
0
       # (what's submitted to the server). It's also possible to use month numbers for the presentation instead of names --
0
- # set the <tt>:use_month_numbers</tt> key in +options+ to true for this to happen. If you want both numbers and names,
0
+ # set the <tt>:use_month_numbers</tt> key in +options+ to true for this to happen. If you want both numbers and names,
0
       # set the <tt>:add_month_numbers</tt> key in +options+ to true. Examples:
0
       #
0
       # select_month(Date.today) # Will use keys like "January", "March"
0
@@ -158,7 +158,7 @@ module ActionView
0
         month_options = []
0
 
0
         1.upto(12) do |month_number|
0
- month_name = if options[:use_month_numbers]
0
+ month_name = if options[:use_month_numbers]
0
             month_number
0
           elsif options[:add_month_numbers]
0
             month_number.to_s + " - " + Date::MONTHNAMES[month_number]
0
@@ -167,16 +167,16 @@ module ActionView
0
           end
0
 
0
           month_options << ((date.kind_of?(Fixnum) ? date : date.month) == month_number ?
0
- %(<option value="#{month_number}" selected="selected">#{month_name}</option>\n) :
0
+ %(<option value="#{month_number}" selected="selected">#{month_name}</option>\n) :
0
             %(<option value="#{month_number}">#{month_name}</option>\n)
0
           )
0
         end
0
 
0
         select_html("month", month_options, options[:prefix], options[:include_blank], options[:discard_type])
0
       end
0
-
0
+
0
       # 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
0
- # can be changed using the <tt>:start_year</tt> and <tt>:end_year</tt> keys in the +options+. The <tt>date</tt> can also be substituted
0
+ # can be changed using the <tt>:start_year</tt> and <tt>:end_year</tt> keys in the +options+. The <tt>date</tt> can also be substituted
0
       # for a year given as a number. Example:
0
       #
0
       # select_year(Date.today, :start_year => 1992, :end_year => 2007)
0
@@ -187,14 +187,14 @@ module ActionView
0
 
0
         (options[:start_year] || default_start_year).upto(options[:end_year] || default_end_year) do |year|
0
           year_options << ((date.kind_of?(Fixnum) ? date : date.year) == year ?
0
- "<option selected=\"selected\">#{year}</option>\n" :
0
+ "<option selected=\"selected\">#{year}</option>\n" :
0
             "<option>#{year}</option>\n"
0
           )
0
         end
0
 
0
         select_html("year", year_options, options[:prefix], options[:include_blank], options[:discard_type])
0
       end
0
-
0
+
0
       private
0
         def select_html(type, options, prefix = nil, include_blank = false, discard_type = false)
0
           select_html = %(<select name="#{prefix || DEFAULT_PREFIX})
0
@@ -206,7 +206,7 @@ module ActionView
0
 
0
           return select_html
0
         end
0
-
0
+
0
         def leading_zero_on_single_digits(number)
0
           number > 9 ? number : "0#{number}"
0
         end
0
@@ -217,32 +217,32 @@ module ActionView
0
 
0
       def to_date_select_tag(options = {})
0
         defaults = { :discard_type => true }
0
- options = defaults.merge(options)
0
- options_with_prefix = Proc.new { |position| options.update({ :prefix => "#{@object_name}[#{@method_name}(#{position}i)]" }) }
0
+ options = defaults.merge(options)
0
+ options_with_prefix = Proc.new { |position| options.merge(:prefix => "#{@object_name}[#{@method_name}(#{position}i)]") }
0
         date = options[:include_blank] ? (value || 0) : (value || Date.today)
0
 
0
- date_select = ""
0
+ date_select = ""
0
         options[:order] = [:month, :year, :day] if options[:month_before_year] # For backwards compatibility
0
         options[:order] ||= [:year, :month, :day]
0
 
0
         position = {:year => 1, :month => 2, :day => 3}
0
-
0
+
0
         discard = {}
0
         discard[:year] = true if options[:discard_year]
0
         discard[:month] = true if options[:discard_month]
0
         discard[:day] = true if options[:discard_day] or options[:discard_month]
0
-
0
+
0
         options[:order].each do |param|
0
           date_select << self.send("select_#{param}", date, options_with_prefix.call(position[param])) unless discard[param]
0
         end
0
 
0
         return date_select
0
       end
0
-
0
+
0
       def to_datetime_select_tag(options = {})
0
         defaults = { :discard_type => true }
0
- options = defaults.merge(options)
0
- options_with_prefix = Proc.new { |position| options.update({ :prefix => "#{@object_name}[#{@method_name}(#{position}i)]" }) }
0
+ options = defaults.merge(options)
0
+ options_with_prefix = Proc.new { |position| options.merge(:prefix => "#{@object_name}[#{@method_name}(#{position}i)]") }
0
         datetime = options[:include_blank] ? (value || 0) : (value || Time.now)
0
 
0
         datetime_select = select_year(datetime, options_with_prefix.call(1))
0
@@ -250,7 +250,7 @@ module ActionView
0
         datetime_select << select_day(datetime, options_with_prefix.call(3)) unless options[:discard_day] || options[:discard_month]
0
         datetime_select << " &mdash; " + select_hour(datetime, options_with_prefix.call(4)) unless options[:discard_hour]
0
         datetime_select << " : " + select_minute(datetime, options_with_prefix.call(5)) unless options[:discard_minute] || options[:discard_hour]
0
-
0
+
0
         return datetime_select
0
       end
0
     end
...
8
9
10
11
 
12
13
14
 
15
16
17
...
26
27
28
29
30
 
 
31
32
33
34
 
 
35
36
37
...
43
44
45
46
 
47
48
49
...
51
52
53
54
 
55
56
57
 
58
59
60
...
64
65
66
67
 
68
69
70
...
95
96
97
98
 
99
100
101
102
103
 
104
105
106
...
119
120
121
122
 
123
124
125
126
127
128
 
129
130
131
...
135
136
137
138
139
140
 
 
 
 
141
142
143
...
146
147
148
149
 
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
169
170
 
171
172
173
174
175
176
177
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
178
179
 
180
181
182
183
 
184
185
186
 
187
188
 
189
190
191
192
 
193
194
195
...
210
211
212
213
 
214
215
216
...
218
219
220
221
222
223
 
 
 
224
225
226
227
 
 
228
229
230
 
 
231
232
233
 
234
235
236
237
 
238
239
240
...
8
9
10
 
11
12
13
 
14
15
16
17
...
26
27
28
 
 
29
30
31
32
 
 
33
34
35
36
37
...
43
44
45
 
46
47
48
49
...
51
52
53
 
54
55
56
 
57
58
59
60
...
64
65
66
 
67
68
69
70
...
95
96
97
 
98
99
100
101
102
 
103
104
105
106
...
119
120
121
 
122
123
124
125
126
127
 
128
129
130
131
...
135
136
137
 
 
 
138
139
140
141
142
143
144
...
147
148
149
 
150
151
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
 
174
175
176
177
178
179
 
 
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
 
199
200
201
202
 
203
204
 
 
205
206
 
207
208
209
210
211
212
213
214
215
...
230
231
232
 
233
234
235
236
...
238
239
240
 
 
 
241
242
243
244
245
 
 
246
247
248
 
 
249
250
251
252
 
253
254
255
256
 
257
258
259
260
0
@@ -8,10 +8,10 @@ module ActionView
0
     # The following is an example of a complete form for a person object that works for both creates and updates built
0
     # with all the form helpers. The <tt>@person</tt> object was assigned by an action on the controller:
0
     # <form action="save_person" method="post">
0
- # Name:
0
+ # Name:
0
     # <%= text_field "person", "name", "size" => 20 %>
0
     #
0
- # Password:
0
+ # Password:
0
     # <%= password_field "person", "password", "maxsize" => 20 %>
0
     #
0
     # Single?:
0
@@ -26,12 +26,12 @@ module ActionView
0
     # ...is compiled to:
0
     #
0
     # <form action="save_person" method="post">
0
- # Name:
0
- # <input type="text" id="person_name" name="person[name]"
0
+ # Name:
0
+ # <input type="text" id="person_name" name="person[name]"
0
     # size="20" value="<%= @person.name %>" />
0
     #
0
- # Password:
0
- # <input type="password" id="person_password" name="person[password]"
0
+ # Password:
0
+ # <input type="password" id="person_password" name="person[password]"
0
     # size="20" maxsize="20" value="<%= @person.password %>" />
0
     #
0
     # Single?:
0
@@ -43,7 +43,7 @@ module ActionView
0
     # </textarea>
0
     #
0
     # <input type="submit" value="Save">
0
- # </form>
0
+ # </form>
0
     #
0
     # If the helper is being used to generate a repetitive sequence of similar form elements, for example in a partial
0
     # used by render_collection_of_partials, the "index" option may come in handy. Example:
0
@@ -51,10 +51,10 @@ module ActionView
0
     # <%= text_field "person", "name", "index" => 1 %>
0
     #
0
     # becomes
0
- #
0
+ #
0
     # <input type="text" id="person_1_name" name="person[1][name]" value="<%= @person.name %>" />
0
     #
0
- # There's also methods for helping to build form tags in link:classes/ActionView/Helpers/FormOptionsHelper.html,
0
+ # There's also methods for helping to build form tags in link:classes/ActionView/Helpers/FormOptionsHelper.html,
0
     # link:classes/ActionView/Helpers/DateHelper.html, and link:classes/ActionView/Helpers/ActiveRecordHelper.html
0
     module FormHelper
0
       # Returns an input tag of the "text" type tailored for accessing a specified attribute (identified by +method+) on an object
0
@@ -64,7 +64,7 @@ module ActionView
0
       # Examples (call, result):
0
       # text_field("post", "title", "size" => 20)
0
       # <input type="text" id="post_title" name="post[title]" size="20" value="#{@post.title}" />
0
- def text_field(object, method, options = {})
0
+ def text_field(object, method, options = {})
0
         InstanceTag.new(object, method, self).to_input_field_tag("text", options)
0
       end
0
 
0
@@ -95,12 +95,12 @@ module ActionView
0
       def text_area(object, method, options = {})
0
         InstanceTag.new(object, method, self).to_text_area_tag(options)
0
       end
0
-
0
+
0
       # Returns a checkbox tag tailored for accessing a specified attribute (identified by +method+) on an object
0
       # assigned to the template (identified by +object+). It's intended that +method+ returns an integer and if that
0
       # integer is above zero, then the checkbox is checked. Additional options on the input tag can be passed as a
0
       # hash with +options+. The +checked_value+ defaults to 1 while the default +unchecked_value+
0
- # is set to 0 which is convenient for boolean values. Usually unchecked checkboxes don't post anything.
0
+ # is set to 0 which is convenient for boolean values. Usually unchecked checkboxes don't post anything.
0
       # We work around this problem by adding a hidden value with the same name as the checkbox.
0
       #
0
       # Example (call, result). Imagine that @post.validated? returns 1:
0
@@ -119,13 +119,13 @@ module ActionView
0
       # Returns a radio button tag for accessing a specified attribute (identified by +method+) on an object
0
       # assigned to the template (identified by +object+). If the current value of +method+ is +tag_value+ the
0
       # radio button will be checked. Additional options on the input tag can be passed as a
0
- # hash with +options+.
0
+ # hash with +options+.
0
       # Example (call, result). Imagine that @post.category returns "rails":
0
       # radio_button("post", "category", "rails")
0
       # radio_button("post", "category", "java")
0
       # <input type="radio" id="post_category" name="post[category] value="rails" checked="checked" />
0
       # <input type="radio" id="post_category" name="post[category] value="java" />
0
- #
0
+ #
0
       def radio_button(object, method, tag_value, options = {})
0
         InstanceTag.new(object, method, self).to_radio_button_tag(tag_value, options)
0
       end
0
@@ -135,9 +135,10 @@ module ActionView
0
       include Helpers::TagHelper
0
 
0
       attr_reader :method_name, :object_name
0
-
0
- DEFAULT_FIELD_OPTIONS = { "size" => 30 } unless const_defined?("DEFAULT_FIELD_OPTIONS")
0
- DEFAULT_TEXT_AREA_OPTIONS = { "wrap" => "virtual", "cols" => 40, "rows" => 20 } unless const_defined?("DEFAULT_TEXT_AREA_OPTIONS")
0
+
0
+ DEFAULT_FIELD_OPTIONS = { "size" => 30 }.freeze unless const_defined?(:DEFAULT_FIELD_OPTIONS)
0
+ DEFAULT_TEXT_AREA_OPTIONS = { "wrap" => "virtual", "cols" => 40, "rows" => 20 }.freeze unless const_defined?(:DEFAULT_TEXT_AREA_OPTIONS)
0
+ DEFAULT_DATE_OPTIONS = { :discard_type => true }.freeze unless const_defined?(:DEFAULT_DATE_OPTIONS)
0
 
0
       def initialize(object_name, method_name, template_object, local_binding = nil)
0
         @object_name, @method_name = object_name, method_name
0
@@ -146,50 +147,69 @@ module ActionView
0
           @auto_index = @template_object.instance_variable_get("@#{Regexp.last_match.pre_match}").id
0
         end
0
       end
0
-
0
+
0
       def to_input_field_tag(field_type, options = {})
0
- html_options = DEFAULT_FIELD_OPTIONS.merge(options)
0
- html_options.merge!({ "size" => options["maxlength"]}) if options["maxlength"] && !options["size"]
0
- html_options.delete("size") if field_type == "hidden"
0
- html_options.merge!({ "type" => field_type})
0
- html_options.merge!({ "value" => value_before_type_cast }) if options["value"].nil? && field_type != "file"
0
- add_default_name_and_id(html_options)
0
- tag("input", html_options)
0
- end
0
-
0
- def to_radio_button_tag(tag_value, options={})
0
- html_options = DEFAULT_FIELD_OPTIONS.merge(options)
0
- html_options.merge!({ "checked" => "checked" }) if value == tag_value
0
- html_options.merge!({ "type" => "radio", "value"=> tag_value.to_s })
0
-
0
- add_default_name_and_id(html_options)
0
-