will_pickdate 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/will_pickdate/pickdate_builder.rb +20 -19
- data/lib/will_pickdate/version.rb +1 -1
- data/lib/will_pickdate.rb +1 -3
- metadata +1 -1
@@ -1,30 +1,31 @@
|
|
1
|
-
module
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
module ActionView
|
2
|
+
module Helpers
|
3
|
+
#FIXME: maybe use datetime_field instead of datetime_field to prevent clash with future versions of rails
|
4
|
+
def datetime_field(object_name, method, options = {})
|
5
5
|
InstanceTag.new(object_name, method, self, options.delete(:object)).to_datetime_field_tag(options)
|
6
|
-
|
6
|
+
end
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
8
|
+
module PickdateHelperInstanceTag
|
9
|
+
def to_datetime_field_tag(options = {})
|
10
|
+
options = options.stringify_keys
|
11
|
+
options = DEFAULT_FIELD_OPTIONS.merge(options)
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
13
|
+
options["type"] = "datetime"
|
14
|
+
options["value"] = options.fetch("value"){ value_before_type_cast(object).iso8601 }
|
15
|
+
options["value"] &&= ERB::Util.html_escape(options["value"])
|
16
|
+
add_default_name_and_id(options)
|
17
|
+
tag("input", options)
|
18
|
+
end
|
18
19
|
end
|
19
|
-
end
|
20
20
|
|
21
|
-
|
22
|
-
|
23
|
-
|
21
|
+
class InstanceTag
|
22
|
+
include PickdateHelperInstanceTag
|
23
|
+
end
|
24
24
|
|
25
|
-
|
25
|
+
class FormBuilder
|
26
26
|
def datetime_field(method, options = {})
|
27
27
|
@template.datetime_select(@object_name, method, objectify_options(options))
|
28
28
|
end
|
29
29
|
end
|
30
|
+
end
|
30
31
|
end
|
data/lib/will_pickdate.rb
CHANGED