simple_form_bootstrap3 0.2.4 → 0.2.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cd1beacf5c4641db392cdbac70092159f1446b59
4
- data.tar.gz: de9ab571777ffc18d12340b68a0caeee7083a036
3
+ metadata.gz: c401b3b54b4828f8e3168c069a2e6823d2fc9924
4
+ data.tar.gz: ab36733744b7a1a89347a52671a1cf4ec28c40cd
5
5
  SHA512:
6
- metadata.gz: 7ad3763abc2b5c9cfe51c3668b0f0245a37e63299ad342b899f11cfb2f7e01de3a36d8b547854a93d5ae1c6f977f4d9421846f10ed8614ecf86a94eb2196ec99
7
- data.tar.gz: d6851fd4df9d46420b749d46bd6358e0df7d0de5ceaf91d48d5e87530280308d56aa6d09c79b2e6db09bf156aee2db875f2d9134bd80b8d3eba1d072e3968a3f
6
+ metadata.gz: ccd6caee6760bc92a44c2f38bfdae48e9939b9a597bdec14d8a670b51bb96464f0a90c7c60406ae9d6c146ac8715e6688c6e5a6d74488d8f908e85f5da285c03
7
+ data.tar.gz: 9f7ded251c5c6b1b0b5459b7332a2b4ef544d5f986d822f3f7fc8559c997a36c138a009cdd6f835a98c7b715b44d396a6f5ed7d5093d842777f1698b264e59d2
data/README.md CHANGED
@@ -17,11 +17,54 @@ And then execute:
17
17
  Or install it yourself as:
18
18
 
19
19
  $ gem install simple_form_bootstrap3
20
+
21
+ See https://github.com/twbs/bootstrap-sass to configure bootstrap gem.
20
22
 
23
+ Add to application.css:
24
+
25
+ *= require bootstrap-datepicker
26
+ *= require bootstrap-datetimepicker
27
+
28
+ Add to application.js:
29
+
30
+ //= require bootstrap-datepicker
31
+ //= require bootstrap-datetimepicker
32
+
33
+ ## Usage (examples with haml)
34
+
35
+ # horizontal form
36
+ = horizontal_form_for @user do |f|
37
+ = f.input :name
38
+ = f.input :password
39
+ = f.checkbox :remember_me
40
+ = f.buttons do
41
+ = f.button :submit
42
+
43
+ # default form
44
+ = default_form_for @user do |f|
45
+ = f.input :name
46
+ = f.checkbox :admin
47
+ = f.button :submit
48
+
49
+ # inline form
50
+ = inline_form_for @user do |f|
51
+ = f.input :name
52
+ = f.checkbox :remember_me
53
+ = f.password
54
+ = f.button :submit
55
+
56
+ # compact form will use placeholder and no labels
57
+ = compact_form_for @user do |f|
58
+ = f.input :name
59
+
21
60
  ## Links
22
61
 
23
62
  Thanks for Sebastien MALOT`s [datepicker](https://github.com/smalot/bootstrap-datepicker) and
24
- [datetimepicker](https://github.com/smalot/bootstrap-datetimepicker)
63
+ [datetimepicker](https://github.com/smalot/bootstrap-datetimepicker).
64
+
65
+ ## TODO
66
+
67
+ Add inline-group wrapper.
25
68
 
26
69
  ## Maintainers and Authors
27
70
 
@@ -11,11 +11,18 @@ module SimpleForm
11
11
  private
12
12
 
13
13
  def input_html_options
14
- options[:value] = Time.zone.parse(options[:value]) if options[:value].is_a? String
14
+ if options.key? :value
15
+ value = options[:value]
16
+ elsif object.respond_to?(attribute_name)
17
+ value = object.send(attribute_name)
18
+ else
19
+ value = ''
20
+ end
21
+
22
+ value = Time.zone.parse(value) if value.is_a?(String)
23
+ value = value.strftime("%Y-%m-%d") if value.respond_to?(:strftime)
15
24
 
16
- { class: 'form-control',
17
- readonly: true,
18
- value: (options[:value].presence || object.send(attribute_name)).strftime("%Y-%m-%d") }
25
+ { class: 'form-control', readonly: true, value: value.presence || '' }
19
26
  end
20
27
 
21
28
  def span_calendar
@@ -11,11 +11,18 @@ module SimpleForm
11
11
  private
12
12
 
13
13
  def input_html_options
14
- options[:value] = Time.zone.parse(options[:value]) if options[:value].is_a? String
14
+ if options.key? :value
15
+ value = options[:value]
16
+ elsif object.respond_to?(attribute_name)
17
+ value = object.send(attribute_name)
18
+ else
19
+ value = ''
20
+ end
21
+
22
+ value = Time.zone.parse(value) if value.is_a?(String)
23
+ value = value.strftime("%Y-%m-%d %H:%M") if value.respond_to?(:strftime)
15
24
 
16
- { class: 'form-control',
17
- readonly: true,
18
- value: (options[:value].presence || object.send(attribute_name)).strftime("%Y-%m-%d %H:%M") }
25
+ { class: 'form-control', readonly: true, value: value.presence || '' }
19
26
  end
20
27
 
21
28
  def span_calendar
@@ -1,3 +1,3 @@
1
1
  module SimpleFormBootstrap3
2
- VERSION = "0.2.4"
2
+ VERSION = "0.2.5"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_form_bootstrap3
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yuriy Kolodovskyy
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-01 00:00:00.000000000 Z
11
+ date: 2014-04-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bootstrap-sass