has_enum 0.7.2 → 0.7.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/has_enum.rb +5 -1
- data/lib/has_enum/formtastic.rb +14 -18
- data/lib/has_enum/version.rb +1 -1
- metadata +2 -1
data/lib/has_enum.rb
CHANGED
data/lib/has_enum/formtastic.rb
CHANGED
@@ -1,24 +1,20 @@
|
|
1
|
-
|
2
|
-
require 'formtastic'
|
1
|
+
Formtastic::SemanticFormBuilder.class_eval do
|
3
2
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
self.select_input(method, options)
|
10
|
-
end
|
3
|
+
def enum_input(method, options = {})
|
4
|
+
options.merge! :collection => object.class.values_for_select_tag(method),
|
5
|
+
:wrapper_html => {:class => :enum}
|
6
|
+
select_input method, options
|
7
|
+
end
|
11
8
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
end
|
9
|
+
def default_input_type_with_enum(method, options={})
|
10
|
+
if object.class.respond_to?(:enums) && object.class.has_enum?(method)
|
11
|
+
:enum
|
12
|
+
else
|
13
|
+
default_input_type_without_enum(method, options)
|
18
14
|
end
|
15
|
+
end
|
19
16
|
|
20
|
-
|
17
|
+
alias_method_chain :default_input_type, :enum
|
21
18
|
|
22
|
-
end
|
23
|
-
rescue LoadError
|
24
19
|
end
|
20
|
+
|
data/lib/has_enum/version.rb
CHANGED