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
|
# File 'lib/freeberry/utils.rb', line 12
def form_field(form_name, field_name, column, options={})
field = case column.type
when :string, :binary, :integer, :float, :decimal then
options[:class] = "'text'"
"text_field"
when :boolean then "check_box"
when :datetime, :date, :timestamp, :time then
options[:extra_html] ||= "<script type='text/javascript'>
$(function() {
$('\##{form_name}_#{field_name}').datepicker({
numberOfMonths: 1,
dateFormat: 'dd.mm.yy'
});
});
</script>"
'text_field'
when :text then
options[:cols] ||= 70
options[:rows] ||= 5
"text_area"
end
= options.delete(:extra_html) || ''
options_fields = []
options.each { |k, v| options_fields << ":#{k}=>#{v}" }
options_str = ", {#{options_fields.join(', ')}}" unless options_fields.empty?
options_str ||= ''
"<%= #{form_name}.#{field} #{field_name}#{options_str} %>#{}"
end
|