formtastic_date_as_string 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,27 +2,6 @@ module FormtasticDateAsString
2
2
  # Your code goes here...
3
3
  end
4
4
 
5
-
6
5
  require 'formtastic'
6
+ require 'formtastic_date_as_string/formtastic'
7
7
 
8
- Formtastic::SemanticFormBuilder.class_eval do
9
-
10
- def date_input(method, options = {})
11
- value = @object.send(method)
12
- options.merge! :as => :string
13
- options.merge! :input_html => { :value => I18n.localize(value)} if value.is_a?(Date)
14
- self.input(method, options).gsub(/class="string/, 'class="date')
15
- end
16
-
17
- def input_with_date(method, options={})
18
- if !options[:as] && @object.is_a?(ActiveRecord::Base) &&
19
- @object.column_for_attribute(method).try(:type) == :date
20
- date_input(method, options)
21
- else
22
- input_without_date(method, options)
23
- end
24
- end
25
-
26
- alias_method_chain :input, :date
27
-
28
- end
@@ -0,0 +1,25 @@
1
+ Formtastic::SemanticFormBuilder.class_eval do
2
+
3
+ def date_input(method, options = {})
4
+ options.merge! :input_html => { :value => I18n.l(object[method]) } if object[method]
5
+ options.merge! :wrapper_html => { :class => :date }
6
+ string_input method, options
7
+ end
8
+
9
+ def default_input_type_with_date(method, options={})
10
+ if date_column? method
11
+ :date
12
+ else
13
+ default_input_type_without_date method, options
14
+ end
15
+ end
16
+
17
+ alias_method_chain :default_input_type, :date
18
+
19
+ protected
20
+
21
+ def date_column?(method)
22
+ object.respond_to?(:column_for_attribute) &&
23
+ object.column_for_attribute(method).try(:type) == :date
24
+ end
25
+ end
@@ -1,3 +1,3 @@
1
1
  module FormtasticDateAsString
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 2
9
- version: 0.0.2
8
+ - 3
9
+ version: 0.0.3
10
10
  platform: ruby
11
11
  authors:
12
12
  - Dmitry Lihachev
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-03-24 00:00:00 +06:00
17
+ date: 2011-03-29 00:00:00 +07:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -45,6 +45,7 @@ files:
45
45
  - Rakefile
46
46
  - formtastic_date_as_string.gemspec
47
47
  - lib/formtastic_date_as_string.rb
48
+ - lib/formtastic_date_as_string/formtastic.rb
48
49
  - lib/formtastic_date_as_string/version.rb
49
50
  has_rdoc: true
50
51
  homepage: http://github.com/openteam/formtastic_date_as_string