simple_form 1.0.3 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of simple_form might be problematic. Click here for more details.
- data/README.rdoc +1 -1
- data/lib/simple_form/action_view_extensions/builder.rb +8 -8
- data/lib/simple_form/components/labels.rb +2 -3
- data/lib/simple_form/form_builder.rb +1 -1
- data/lib/simple_form/inputs/base.rb +13 -1
- data/lib/simple_form/locale/en.yml +3 -3
- data/lib/simple_form/version.rb +1 -1
- data/test/form_builder_test.rb +2 -2
- data/test/test_helper.rb +1 -0
- metadata +4 -4
data/README.rdoc
CHANGED
@@ -238,7 +238,7 @@ Creates a collection of radio inputs with labels associated (same API as collect
|
|
238
238
|
Creates a collection of check boxes with labels associated (same API as collection_select):
|
239
239
|
|
240
240
|
form_for @user do |f|
|
241
|
-
f.
|
241
|
+
f.collection_check_boxes :options, [[true, 'Yes'] ,[false, 'No']], :first, :last
|
242
242
|
end
|
243
243
|
|
244
244
|
<input name="user[options][]" type="hidden" value="" />
|
@@ -36,8 +36,8 @@ module SimpleForm
|
|
36
36
|
|
37
37
|
default_html_options = default_html_options_for_collection(item, value, options, html_options)
|
38
38
|
|
39
|
-
|
40
|
-
|
39
|
+
result << radio_button(attribute, value, default_html_options) <<
|
40
|
+
label("#{attribute}_#{value}", text, :class => "collection_radio")
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
@@ -48,15 +48,15 @@ module SimpleForm
|
|
48
48
|
# == Examples
|
49
49
|
#
|
50
50
|
# form_for @user do |f|
|
51
|
-
# f.
|
51
|
+
# f.collection_check_boxes :options, [[true, 'Yes'] ,[false, 'No']], :first, :last
|
52
52
|
# end
|
53
53
|
#
|
54
54
|
# <input name="user[options][]" type="hidden" value="" />
|
55
55
|
# <input id="user_options_true" name="user[options][]" type="checkbox" value="true" />
|
56
|
-
# <label class="
|
56
|
+
# <label class="collection_check_boxes" for="user_options_true">Yes</label>
|
57
57
|
# <input name="user[options][]" type="hidden" value="" />
|
58
58
|
# <input id="user_options_false" name="user[options][]" type="checkbox" value="false" />
|
59
|
-
# <label class="
|
59
|
+
# <label class="collection_check_boxes" for="user_options_false">No</label>
|
60
60
|
#
|
61
61
|
# == Options
|
62
62
|
#
|
@@ -76,8 +76,8 @@ module SimpleForm
|
|
76
76
|
default_html_options = default_html_options_for_collection(item, value, options, html_options)
|
77
77
|
default_html_options[:multiple] = true
|
78
78
|
|
79
|
-
|
80
|
-
|
79
|
+
result << check_box(attribute, default_html_options, value, '') <<
|
80
|
+
label("#{attribute}_#{value}", text, :class => "collection_check_boxes")
|
81
81
|
end
|
82
82
|
end
|
83
83
|
|
@@ -101,7 +101,7 @@ module SimpleForm
|
|
101
101
|
# Generate default options for collection helpers, such as :checked and
|
102
102
|
# :disabled.
|
103
103
|
def default_html_options_for_collection(item, value, options, html_options) #:nodoc:
|
104
|
-
|
104
|
+
html_options.dup.tap do |default_html_options|
|
105
105
|
[:checked, :disabled].each do |option|
|
106
106
|
next unless options[option]
|
107
107
|
|
@@ -28,8 +28,7 @@ module SimpleForm
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def label_text
|
31
|
-
|
32
|
-
result.respond_to?(:html_safe) ? result.html_safe : result
|
31
|
+
html_safe(SimpleForm.label_text.call(raw_label_text, required_label_text))
|
33
32
|
end
|
34
33
|
|
35
34
|
def label_target
|
@@ -66,4 +65,4 @@ module SimpleForm
|
|
66
65
|
end
|
67
66
|
end
|
68
67
|
end
|
69
|
-
end
|
68
|
+
end
|
@@ -39,7 +39,8 @@ module SimpleForm
|
|
39
39
|
send(component)
|
40
40
|
end
|
41
41
|
content.compact!
|
42
|
-
|
42
|
+
content = html_safe(content.join)
|
43
|
+
html_safe(wrap(content))
|
43
44
|
end
|
44
45
|
|
45
46
|
protected
|
@@ -64,6 +65,17 @@ module SimpleForm
|
|
64
65
|
html_options
|
65
66
|
end
|
66
67
|
|
68
|
+
# Ensure we make html safe only if it responds to it.
|
69
|
+
def html_safe(content)
|
70
|
+
if content.respond_to?(:html_safe)
|
71
|
+
content.html_safe
|
72
|
+
elsif content.respond_to?(:html_safe!)
|
73
|
+
content.html_safe!
|
74
|
+
else
|
75
|
+
content
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
67
79
|
# Lookup translations for the given namespace using I18n, based on object name,
|
68
80
|
# actual action and attribute name. Lookup priority as follows:
|
69
81
|
#
|
@@ -3,9 +3,9 @@ en:
|
|
3
3
|
"yes": 'Yes'
|
4
4
|
"no": 'No'
|
5
5
|
buttons:
|
6
|
-
create: 'Create {
|
7
|
-
update: 'Update {
|
8
|
-
submit: 'Submit {
|
6
|
+
create: 'Create %{model}'
|
7
|
+
update: 'Update %{model}'
|
8
|
+
submit: 'Submit %{model}'
|
9
9
|
required:
|
10
10
|
text: 'required'
|
11
11
|
mark: '*'
|
data/lib/simple_form/version.rb
CHANGED
data/test/form_builder_test.rb
CHANGED
@@ -366,7 +366,7 @@ class FormBuilderTest < ActionView::TestCase
|
|
366
366
|
|
367
367
|
test 'builder should create object buttons with localized labels' do
|
368
368
|
store_translations(:en, :simple_form => { :buttons => {
|
369
|
-
:create => "Criar {
|
369
|
+
:create => "Criar %{model}", :update => "Atualizar %{model}" }}) do
|
370
370
|
with_button_for @user, :submit
|
371
371
|
assert_select 'form input[type=submit][value=Atualizar User]'
|
372
372
|
|
@@ -377,7 +377,7 @@ class FormBuilderTest < ActionView::TestCase
|
|
377
377
|
end
|
378
378
|
|
379
379
|
test 'builder should create non object buttons with localized labels' do
|
380
|
-
store_translations(:en, :simple_form => { :buttons => { :submit => "Enviar {
|
380
|
+
store_translations(:en, :simple_form => { :buttons => { :submit => "Enviar %{model}" }}) do
|
381
381
|
with_button_for :post, :submit
|
382
382
|
assert_select 'form input[type=submit][value=Enviar Post]'
|
383
383
|
end
|
data/test/test_helper.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple_form
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 31
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.
|
9
|
+
- 4
|
10
|
+
version: 1.0.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- "Jos\xC3\xA9 Valim"
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2010-08
|
19
|
+
date: 2010-10-08 00:00:00 -03:00
|
20
20
|
default_executable:
|
21
21
|
dependencies: []
|
22
22
|
|