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
|
# File 'lib/validations/form_helper.rb', line 3
def self.included base
base.class_eval do
alias origin_text_field text_field
def text_field object_name, method = nil, options = {}
model = eval(@object_name.to_s.classify)
validation_rules = {}
if defined? model.get_validation_rules
validation_rules = \
model.get_validation_rules object_name
end
if method and method.class == Hash
origin_text_field object_name, method.merge(validation_rules || {})
elsif method
origin_text_field object_name, method, options.merge(validation_rules || {})
else
origin_text_field object_name, (validation_rules || {})
end
end
end
end
|