3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
# File 'lib/helpers/defaulted.rb', line 3
def self.included base
base.class_eval do
alias railsjs__defaulted_text_field text_field
def text_field object_name, method = nil, options = {}
method_copy = method ? method.clone : nil
if method_copy and method_copy.class == Hash
if default_value = method_copy[:default]
method_copy.delete :default
method_copy['data-default-value'] = default_value
end
railsjs__defaulted_text_field \
object_name, method_copy
elsif method
railsjs__defaulted_text_field \
object_name, method, options
else
railsjs__defaulted_text_field \
object_name, {}
end
end
alias railsjs__defaulted_password_field password_field
def password_field object_name, method = nil, options = {}
method_copy = method ? method.clone : nil
if method_copy and method_copy.class == Hash
if default_value = method_copy[:default]
method_copy.delete :default
method_copy['data-default-value'] = default_value
end
railsjs__defaulted_password_field \
object_name, method_copy
elsif method
debugger
railsjs__defaulted_password_field \
object_name, method, options
else
railsjs__defaulted_password_field \
object_name, {}
end
end
end
end
|