cielo_assets 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
data/README.md
CHANGED
@@ -79,3 +79,44 @@ You can provide any arbitrary css class since you define it at your own applicat
|
|
79
79
|
<%= f.cielo_controls :field %>
|
80
80
|
<%= f.submit %>
|
81
81
|
<% end %>
|
82
|
+
|
83
|
+
## Validation and FieldWithErrors workaround
|
84
|
+
|
85
|
+
When rails fields fails to validate, the corresponding field is surrounded by a div with field_with_errors
|
86
|
+
class. This breaks CieloAssets behavior, because it expects input and labels are adjacent, to highlight
|
87
|
+
the checked control:
|
88
|
+
|
89
|
+
input {
|
90
|
+
display: none;
|
91
|
+
&:checked + label {
|
92
|
+
border-color: #777;
|
93
|
+
}
|
94
|
+
}
|
95
|
+
|
96
|
+
To avoid this side effect, add
|
97
|
+
[this workaround](http://stackoverflow.com/questions/5267998/rails-3-field-with-errors-wrapper-changes-the-page-appearance-how-to-avoid-t)
|
98
|
+
on your project's ``` config/application.rb ```:
|
99
|
+
|
100
|
+
config.action_view.field_error_proc = Proc.new { |html_tag, instance|
|
101
|
+
if instance.object.respond_to? "disable_field_with_errors_for_#{instance.method_name}"
|
102
|
+
html_tag.html_safe
|
103
|
+
else
|
104
|
+
"<div class=\"field_with_errors\">#{html_tag}</div>".html_safe
|
105
|
+
end
|
106
|
+
}
|
107
|
+
|
108
|
+
and declare the fields (via attr_reader or an empty method, for example)
|
109
|
+
that should not be surrounded by ``` field_with_errors ``` div when validation fails:
|
110
|
+
|
111
|
+
# supposes attribute is named cielo_flag
|
112
|
+
attr_accessible :cielo_flag
|
113
|
+
|
114
|
+
attr_reader :disable_field_with_errors_for_cielo_flag
|
115
|
+
|
116
|
+
or
|
117
|
+
|
118
|
+
# supposes attribute is named flag
|
119
|
+
attr_accessible :flag
|
120
|
+
|
121
|
+
def disable_field_with_errors_for_flag
|
122
|
+
end
|
@@ -4,11 +4,18 @@ module CieloAssets
|
|
4
4
|
id = options.delete(:id) || :cielo_controls
|
5
5
|
style = options.delete(:style) || :horizontal
|
6
6
|
|
7
|
+
# object is deleted by radio_button helper,
|
8
|
+
# so it must be re-added to options every flag
|
9
|
+
object = options[:object]
|
10
|
+
|
7
11
|
content_tag :div, id: id, class: style do
|
8
|
-
|
12
|
+
%w(amex diners elo mastercard mastercard_securecode verified_by_visa visa).collect { |flag|
|
13
|
+
options.merge! object: object
|
14
|
+
radio = radio_button object_name, method, flag, options
|
15
|
+
radio_id = radio.to_s.scan(/id=\"([^"]*)/).flatten.first
|
16
|
+
label_options = options.merge class: "#{flag} selectable", for: radio_id
|
9
17
|
[
|
10
|
-
|
11
|
-
label("#{object_name}_#{method}", flag, options.merge(class: "#{flag} selectable"))
|
18
|
+
radio, label(radio_id, flag, label_options)
|
12
19
|
].join.html_safe
|
13
20
|
}.join.html_safe
|
14
21
|
end
|
data/lib/cielo_assets/engine.rb
CHANGED
data/lib/cielo_assets/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cielo_assets
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-02-
|
12
|
+
date: 2013-02-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -169,7 +169,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
169
169
|
version: '0'
|
170
170
|
segments:
|
171
171
|
- 0
|
172
|
-
hash: -
|
172
|
+
hash: -665081776306586388
|
173
173
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
174
174
|
none: false
|
175
175
|
requirements:
|
@@ -178,7 +178,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
178
178
|
version: '0'
|
179
179
|
segments:
|
180
180
|
- 0
|
181
|
-
hash: -
|
181
|
+
hash: -665081776306586388
|
182
182
|
requirements: []
|
183
183
|
rubyforge_project:
|
184
184
|
rubygems_version: 1.8.23
|