simple_form 3.1.0.rc1 → 3.1.0.rc2
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -1
- data/README.md +37 -6
- data/lib/generators/simple_form/templates/config/initializers/simple_form.rb +6 -2
- data/lib/generators/simple_form/templates/config/initializers/simple_form_bootstrap.rb +37 -14
- data/lib/simple_form.rb +8 -0
- data/lib/simple_form/components/labels.rb +1 -1
- data/lib/simple_form/form_builder.rb +29 -15
- data/lib/simple_form/inputs/boolean_input.rb +7 -4
- data/lib/simple_form/tags.rb +1 -0
- data/lib/simple_form/version.rb +1 -1
- data/lib/simple_form/wrappers/builder.rb +2 -2
- data/lib/simple_form/wrappers/many.rb +1 -0
- data/test/action_view_extensions/builder_test.rb +3 -3
- data/test/action_view_extensions/form_helper_test.rb +13 -13
- data/test/components/label_test.rb +35 -35
- data/test/form_builder/association_test.rb +4 -4
- data/test/form_builder/button_test.rb +5 -5
- data/test/form_builder/error_test.rb +18 -18
- data/test/form_builder/general_test.rb +65 -60
- data/test/form_builder/hint_test.rb +15 -15
- data/test/form_builder/input_field_test.rb +16 -16
- data/test/form_builder/label_test.rb +22 -13
- data/test/form_builder/wrapper_test.rb +54 -20
- data/test/inputs/boolean_input_test.rb +8 -8
- data/test/inputs/collection_check_boxes_input_test.rb +24 -7
- data/test/inputs/collection_radio_buttons_input_test.rb +40 -23
- data/test/inputs/collection_select_input_test.rb +45 -45
- data/test/inputs/datetime_input_test.rb +23 -23
- data/test/inputs/disabled_test.rb +15 -15
- data/test/inputs/discovery_test.rb +44 -5
- data/test/inputs/file_input_test.rb +2 -2
- data/test/inputs/general_test.rb +20 -20
- data/test/inputs/grouped_collection_select_input_test.rb +2 -2
- data/test/inputs/hidden_input_test.rb +4 -4
- data/test/inputs/numeric_input_test.rb +24 -24
- data/test/inputs/priority_input_test.rb +7 -7
- data/test/inputs/readonly_test.rb +19 -19
- data/test/inputs/required_test.rb +13 -13
- data/test/inputs/string_input_test.rb +23 -23
- data/test/inputs/text_input_test.rb +4 -4
- data/test/support/discovery_inputs.rb +20 -0
- data/test/support/misc_helpers.rb +22 -0
- data/test/support/models.rb +2 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 88d85494e222c13d302bed66c947ebc999702a46
|
4
|
+
data.tar.gz: 6974cf74dc9cada33d515c0125c4506262aa4118
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c2f1599b149fd691ccc0471af01e5f2f997465f55449bfea0924768c45f83510d36911342e54e8c42dfa75adf5da278261188f17c938b3571446b97c419e2011
|
7
|
+
data.tar.gz: 4c1677e4c36aa1381a378ef3a2c688db1881089d014cb97078f14dd2f5000a618fddc9671f78663fd693c86e4bc8524f3f2c9837aa5e8f7707c9b07b223cf114
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,9 @@
|
|
1
|
-
## 3.1.0.
|
1
|
+
## 3.1.0.rc2
|
2
2
|
|
3
3
|
### enhancements
|
4
|
+
* Add mapping to `uuid` columns.
|
5
|
+
* Add custom namespaces for custom inputs feature. [@vala](https://github.com/vala)
|
6
|
+
* Add `:unless_blank` option to the wrapper API. [@IanVaughan](https://github.com/IanVaughan)
|
4
7
|
* Add support to html markup in the I18n options. [@laurocaetano](https://github.com/laurocaetano)
|
5
8
|
* Add the `full_error` component. [@laurocaetano](https://github.com/laurocaetano)
|
6
9
|
* Add support to `scope` to be used on associations. [@laurocaetano](https://github.com/laurocaetano)
|
data/README.md
CHANGED
@@ -259,7 +259,7 @@ end
|
|
259
259
|
```
|
260
260
|
|
261
261
|
For check boxes and radio buttons you can remove the label changing `boolean_style` from default value `:nested` to `:inline`.
|
262
|
-
Also, `
|
262
|
+
Also, `item_wrapper_tag` will not work when `boolean_style` is set to `:nested`.
|
263
263
|
|
264
264
|
Example:
|
265
265
|
|
@@ -521,6 +521,7 @@ specifying the helper method in the column `Mapping` as the `as:` option.
|
|
521
521
|
`tel` | `input[type=tel]` | `string` with `name =~ /phone/`
|
522
522
|
`password` | `input[type=password]` | `string` with `name =~ /password/`
|
523
523
|
`search` | `input[type=search]` | -
|
524
|
+
`uuid` | `input[type=text]` | `uuid`
|
524
525
|
`text` | `textarea` | `text`
|
525
526
|
`file` | `input[type=file]` | `string` responding to file methods
|
526
527
|
`hidden` | `input[type=hidden]` | -
|
@@ -581,6 +582,28 @@ class CollectionSelectInput < SimpleForm::Inputs::CollectionSelectInput
|
|
581
582
|
end
|
582
583
|
```
|
583
584
|
|
585
|
+
If needed, you can namespace your custom inputs in a module and tell **Simple Form** to look for
|
586
|
+
their definitions in this module. This can avoid conflicts with other form libraries (like Formtastic) that look up
|
587
|
+
the global context to find inputs definition too.
|
588
|
+
|
589
|
+
```ruby
|
590
|
+
# app/inputs/custom_inputs/numeric_input
|
591
|
+
module CustomInputs
|
592
|
+
class NumericInput < SimpleForm::Inputs::NumericInput
|
593
|
+
def input_html_classes
|
594
|
+
super.push('no-spinner')
|
595
|
+
end
|
596
|
+
end
|
597
|
+
end
|
598
|
+
```
|
599
|
+
|
600
|
+
And in the **SimpleForm** initializer :
|
601
|
+
|
602
|
+
```ruby
|
603
|
+
# config/simple_form.rb
|
604
|
+
config.custom_inputs_namespaces << "CustomInputs"
|
605
|
+
```
|
606
|
+
|
584
607
|
## Custom form builder
|
585
608
|
|
586
609
|
You can create a custom form builder that uses **Simple Form**.
|
@@ -599,8 +622,7 @@ Create a form builder class that inherits from `SimpleForm::FormBuilder`.
|
|
599
622
|
```ruby
|
600
623
|
class CustomFormBuilder < SimpleForm::FormBuilder
|
601
624
|
def input(attribute_name, options = {}, &block)
|
602
|
-
options
|
603
|
-
super
|
625
|
+
super(attribute_name, options.merge(label: false), &block)
|
604
626
|
end
|
605
627
|
end
|
606
628
|
```
|
@@ -629,8 +651,8 @@ en:
|
|
629
651
|
user:
|
630
652
|
age: 'Rather not say'
|
631
653
|
prompts:
|
632
|
-
|
633
|
-
|
654
|
+
user:
|
655
|
+
gender: 'Select your gender'
|
634
656
|
```
|
635
657
|
|
636
658
|
And your forms will use this information to render the components for you.
|
@@ -896,6 +918,15 @@ end
|
|
896
918
|
By setting it as `optional`, a hint will only be generated when `hint: true` is explicitly used.
|
897
919
|
The same for placeholder.
|
898
920
|
|
921
|
+
It is also possible to give the option `:unless_blank` to the wrapper if you want to render it only
|
922
|
+
when the content is present.
|
923
|
+
|
924
|
+
```ruby
|
925
|
+
b.wrapper tag: :span, class: 'hint', unless_blank: true do |component|
|
926
|
+
component.optional :hint
|
927
|
+
end
|
928
|
+
```
|
929
|
+
|
899
930
|
## HTML 5 Notice
|
900
931
|
|
901
932
|
By default, **Simple Form** will generate input field types and attributes that are supported in HTML5,
|
@@ -985,7 +1016,7 @@ https://github.com/plataformatec/simple_form/issues
|
|
985
1016
|
[![Gem Version](https://fury-badge.herokuapp.com/rb/simple_form.png)](http://badge.fury.io/rb/simple_form)
|
986
1017
|
[![Build Status](https://api.travis-ci.org/plataformatec/simple_form.svg?branch=master)](http://travis-ci.org/plataformatec/simple_form)
|
987
1018
|
[![Code Climate](https://codeclimate.com/github/plataformatec/simple_form.png)](https://codeclimate.com/github/plataformatec/simple_form)
|
988
|
-
[![Inline docs](http://inch-
|
1019
|
+
[![Inline docs](http://inch-ci.org/github/plataformatec/simple_form.png)](http://inch-ci.org/github/plataformatec/simple_form)
|
989
1020
|
|
990
1021
|
## License
|
991
1022
|
|
@@ -22,9 +22,9 @@ SimpleForm.setup do |config|
|
|
22
22
|
b.use :placeholder
|
23
23
|
|
24
24
|
## Optional extensions
|
25
|
-
# They are disabled unless you pass `f.input EXTENSION_NAME =>
|
25
|
+
# They are disabled unless you pass `f.input EXTENSION_NAME => true`
|
26
26
|
# to the input. If so, they will retrieve the values from the model
|
27
|
-
# if any exists. If you want to enable
|
27
|
+
# if any exists. If you want to enable any of those
|
28
28
|
# extensions by default, you can change `b.optional` to `b.use`.
|
29
29
|
|
30
30
|
# Calculates maxlength from length validations for string inputs
|
@@ -131,6 +131,10 @@ SimpleForm.setup do |config|
|
|
131
131
|
# type as key and the wrapper that will be used for all inputs with specified type.
|
132
132
|
# config.wrapper_mappings = { string: :prepend }
|
133
133
|
|
134
|
+
# Namespaces where SimpleForm should look for custom input classes that
|
135
|
+
# override default inputs.
|
136
|
+
# config.custom_inputs_namespaces << "CustomInputs"
|
137
|
+
|
134
138
|
# Default priority for time_zone inputs.
|
135
139
|
# config.time_zone_priority = nil
|
136
140
|
|
@@ -1,35 +1,38 @@
|
|
1
1
|
# Use this setup block to configure all options available in SimpleForm.
|
2
2
|
SimpleForm.setup do |config|
|
3
|
+
config.error_notification_class = 'alert alert-danger'
|
3
4
|
config.button_class = 'btn btn-default'
|
4
5
|
config.boolean_label_class = nil
|
5
6
|
|
6
7
|
config.wrappers :vertical_form, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
|
7
8
|
b.use :html5
|
8
9
|
b.use :placeholder
|
10
|
+
b.optional :maxlength
|
11
|
+
b.optional :pattern
|
12
|
+
b.optional :min_max
|
13
|
+
b.optional :readonly
|
9
14
|
b.use :label, class: 'control-label'
|
10
15
|
|
11
|
-
b.
|
12
|
-
|
13
|
-
|
14
|
-
ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
|
15
|
-
end
|
16
|
+
b.use :input, class: 'form-control'
|
17
|
+
b.use :error, wrap_with: { tag: 'span', class: 'help-block' }
|
18
|
+
b.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
|
16
19
|
end
|
17
20
|
|
18
21
|
config.wrappers :vertical_file_input, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
|
19
22
|
b.use :html5
|
20
23
|
b.use :placeholder
|
24
|
+
b.optional :maxlength
|
25
|
+
b.optional :readonly
|
21
26
|
b.use :label, class: 'control-label'
|
22
27
|
|
23
|
-
b.
|
24
|
-
|
25
|
-
|
26
|
-
ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
|
27
|
-
end
|
28
|
+
b.use :input
|
29
|
+
b.use :error, wrap_with: { tag: 'span', class: 'help-block' }
|
30
|
+
b.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
|
28
31
|
end
|
29
32
|
|
30
33
|
config.wrappers :vertical_boolean, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
|
31
34
|
b.use :html5
|
32
|
-
b.
|
35
|
+
b.optional :readonly
|
33
36
|
|
34
37
|
b.wrapper tag: 'div', class: 'checkbox' do |ba|
|
35
38
|
ba.use :label_input
|
@@ -41,7 +44,7 @@ SimpleForm.setup do |config|
|
|
41
44
|
|
42
45
|
config.wrappers :vertical_radio_and_checkboxes, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
|
43
46
|
b.use :html5
|
44
|
-
b.
|
47
|
+
b.optional :readonly
|
45
48
|
b.use :label_input
|
46
49
|
b.use :error, wrap_with: { tag: 'span', class: 'help-block' }
|
47
50
|
b.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
|
@@ -50,6 +53,10 @@ SimpleForm.setup do |config|
|
|
50
53
|
config.wrappers :horizontal_form, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
|
51
54
|
b.use :html5
|
52
55
|
b.use :placeholder
|
56
|
+
b.optional :maxlength
|
57
|
+
b.optional :pattern
|
58
|
+
b.optional :min_max
|
59
|
+
b.optional :readonly
|
53
60
|
b.use :label, class: 'col-sm-3 control-label'
|
54
61
|
|
55
62
|
b.wrapper tag: 'div', class: 'col-sm-9' do |ba|
|
@@ -62,6 +69,8 @@ SimpleForm.setup do |config|
|
|
62
69
|
config.wrappers :horizontal_file_input, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
|
63
70
|
b.use :html5
|
64
71
|
b.use :placeholder
|
72
|
+
b.optional :maxlength
|
73
|
+
b.optional :readonly
|
65
74
|
b.use :label, class: 'col-sm-3 control-label'
|
66
75
|
|
67
76
|
b.wrapper tag: 'div', class: 'col-sm-9' do |ba|
|
@@ -73,7 +82,7 @@ SimpleForm.setup do |config|
|
|
73
82
|
|
74
83
|
config.wrappers :horizontal_boolean, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
|
75
84
|
b.use :html5
|
76
|
-
b.
|
85
|
+
b.optional :readonly
|
77
86
|
|
78
87
|
b.wrapper tag: 'div', class: 'col-sm-offset-3 col-sm-9' do |wr|
|
79
88
|
wr.wrapper tag: 'div', class: 'checkbox' do |ba|
|
@@ -87,7 +96,7 @@ SimpleForm.setup do |config|
|
|
87
96
|
|
88
97
|
config.wrappers :horizontal_radio_and_checkboxes, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
|
89
98
|
b.use :html5
|
90
|
-
b.
|
99
|
+
b.optional :readonly
|
91
100
|
|
92
101
|
b.use :label, class: 'col-sm-3 control-label'
|
93
102
|
|
@@ -98,6 +107,20 @@ SimpleForm.setup do |config|
|
|
98
107
|
end
|
99
108
|
end
|
100
109
|
|
110
|
+
config.wrappers :inline_form, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
|
111
|
+
b.use :html5
|
112
|
+
b.use :placeholder
|
113
|
+
b.optional :maxlength
|
114
|
+
b.optional :pattern
|
115
|
+
b.optional :min_max
|
116
|
+
b.optional :readonly
|
117
|
+
b.use :label, class: 'sr-only'
|
118
|
+
|
119
|
+
b.use :input, class: 'form-control'
|
120
|
+
b.use :error, wrap_with: { tag: 'span', class: 'help-block' }
|
121
|
+
b.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
|
122
|
+
end
|
123
|
+
|
101
124
|
# Wrappers for forms and inputs using the Bootstrap toolkit.
|
102
125
|
# Check the Bootstrap docs (http://getbootstrap.com)
|
103
126
|
# to learn about the different styles for forms and inputs,
|
data/lib/simple_form.rb
CHANGED
@@ -130,6 +130,14 @@ See https://github.com/plataformatec/simple_form/pull/997 for more information.
|
|
130
130
|
mattr_accessor :wrapper_mappings
|
131
131
|
@@wrapper_mappings = nil
|
132
132
|
|
133
|
+
# Namespaces where SimpleForm should look for custom input classes that override
|
134
|
+
# default inputs. Namespaces are given as string to allow lazy loading inputs.
|
135
|
+
# e.g. config.custom_inputs_namespaces << "CustomInputs"
|
136
|
+
# will try to find CustomInputs::NumericInput when an :integer
|
137
|
+
# field is called.
|
138
|
+
mattr_accessor :custom_inputs_namespaces
|
139
|
+
@@custom_inputs_namespaces = []
|
140
|
+
|
133
141
|
# Default priority for time_zone inputs.
|
134
142
|
mattr_accessor :time_zone_priority
|
135
143
|
@@time_zone_priority = nil
|
@@ -31,7 +31,7 @@ module SimpleForm
|
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
|
-
def label_text
|
34
|
+
def label_text(wrapper_options = nil)
|
35
35
|
label_text = options[:label_text] || SimpleForm.label_text
|
36
36
|
label_text.call(html_escape(raw_label_text), required_label_text, options[:label].present?).strip.html_safe
|
37
37
|
end
|
@@ -17,19 +17,19 @@ module SimpleForm
|
|
17
17
|
extend MapType
|
18
18
|
include SimpleForm::Inputs
|
19
19
|
|
20
|
-
map_type :text,
|
21
|
-
map_type :file,
|
22
|
-
map_type :string, :email, :search, :tel, :url, to: SimpleForm::Inputs::StringInput
|
23
|
-
map_type :password,
|
24
|
-
map_type :integer, :decimal, :float,
|
25
|
-
map_type :range,
|
26
|
-
map_type :check_boxes,
|
27
|
-
map_type :radio_buttons,
|
28
|
-
map_type :select,
|
29
|
-
map_type :grouped_select,
|
30
|
-
map_type :date, :time, :datetime,
|
31
|
-
map_type :country, :time_zone,
|
32
|
-
map_type :boolean,
|
20
|
+
map_type :text, to: SimpleForm::Inputs::TextInput
|
21
|
+
map_type :file, to: SimpleForm::Inputs::FileInput
|
22
|
+
map_type :string, :email, :search, :tel, :url, :uuid, to: SimpleForm::Inputs::StringInput
|
23
|
+
map_type :password, to: SimpleForm::Inputs::PasswordInput
|
24
|
+
map_type :integer, :decimal, :float, to: SimpleForm::Inputs::NumericInput
|
25
|
+
map_type :range, to: SimpleForm::Inputs::RangeInput
|
26
|
+
map_type :check_boxes, to: SimpleForm::Inputs::CollectionCheckBoxesInput
|
27
|
+
map_type :radio_buttons, to: SimpleForm::Inputs::CollectionRadioButtonsInput
|
28
|
+
map_type :select, to: SimpleForm::Inputs::CollectionSelectInput
|
29
|
+
map_type :grouped_select, to: SimpleForm::Inputs::GroupedCollectionSelectInput
|
30
|
+
map_type :date, :time, :datetime, to: SimpleForm::Inputs::DateTimeInput
|
31
|
+
map_type :country, :time_zone, to: SimpleForm::Inputs::PriorityInput
|
32
|
+
map_type :boolean, to: SimpleForm::Inputs::BooleanInput
|
33
33
|
|
34
34
|
def self.discovery_cache
|
35
35
|
@discovery_cache ||= {}
|
@@ -566,7 +566,9 @@ module SimpleForm
|
|
566
566
|
mapping_override(mapping) || mapping
|
567
567
|
else
|
568
568
|
camelized = "#{input_type.to_s.camelize}Input"
|
569
|
-
|
569
|
+
attempt_mapping_with_custom_namespace(camelized) ||
|
570
|
+
attempt_mapping(camelized, Object) ||
|
571
|
+
attempt_mapping(camelized, self.class) ||
|
570
572
|
raise("No input found for #{input_type}")
|
571
573
|
end
|
572
574
|
end
|
@@ -604,7 +606,9 @@ module SimpleForm
|
|
604
606
|
def mapping_override(klass)
|
605
607
|
name = klass.name
|
606
608
|
if name =~ /^SimpleForm::Inputs/
|
607
|
-
|
609
|
+
input_name = name.split("::").last
|
610
|
+
attempt_mapping_with_custom_namespace(input_name) ||
|
611
|
+
attempt_mapping(input_name, Object)
|
608
612
|
end
|
609
613
|
end
|
610
614
|
|
@@ -617,5 +621,15 @@ module SimpleForm
|
|
617
621
|
raise if e.message !~ /#{mapping}$/
|
618
622
|
end
|
619
623
|
end
|
624
|
+
|
625
|
+
def attempt_mapping_with_custom_namespace(input_name)
|
626
|
+
SimpleForm.custom_inputs_namespaces.each do |namespace|
|
627
|
+
if (mapping = attempt_mapping(input_name, namespace.constantize))
|
628
|
+
return mapping
|
629
|
+
end
|
630
|
+
end
|
631
|
+
|
632
|
+
nil
|
633
|
+
end
|
620
634
|
end
|
621
635
|
end
|
@@ -16,7 +16,7 @@ module SimpleForm
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def label_input(wrapper_options = nil)
|
19
|
-
if options[:label] == false
|
19
|
+
if options[:label] == false || inline_label?
|
20
20
|
input(wrapper_options)
|
21
21
|
elsif nested_boolean_style?
|
22
22
|
html_options = label_html_options.dup
|
@@ -61,13 +61,16 @@ module SimpleForm
|
|
61
61
|
@builder.hidden_field(attribute_name, options)
|
62
62
|
end
|
63
63
|
|
64
|
+
def inline_label?
|
65
|
+
nested_boolean_style? && options[:inline_label]
|
66
|
+
end
|
67
|
+
|
64
68
|
def inline_label
|
65
69
|
inline_option = options[:inline_label]
|
66
70
|
|
67
71
|
if inline_option
|
68
|
-
label = inline_option == true ?
|
69
|
-
|
70
|
-
label.html_safe
|
72
|
+
label = inline_option == true ? label_text : html_escape(inline_option)
|
73
|
+
" #{label}".html_safe
|
71
74
|
end
|
72
75
|
end
|
73
76
|
|
data/lib/simple_form/tags.rb
CHANGED
@@ -19,6 +19,7 @@ module SimpleForm
|
|
19
19
|
label_options = {}
|
20
20
|
add_default_name_and_id_for_value(value, label_options)
|
21
21
|
label_options['for'] = label_options.delete('id')
|
22
|
+
label_options['class'] = @options[:item_label_class]
|
22
23
|
rendered_item = content_tag(:label, rendered_item, label_options)
|
23
24
|
end
|
24
25
|
|
data/lib/simple_form/version.rb
CHANGED
@@ -45,7 +45,7 @@ module SimpleForm
|
|
45
45
|
@components = []
|
46
46
|
end
|
47
47
|
|
48
|
-
def use(name, options = {}
|
48
|
+
def use(name, options = {})
|
49
49
|
if options && wrapper = options[:wrap_with]
|
50
50
|
@components << Single.new(name, wrapper, options.except(:wrap_with))
|
51
51
|
else
|
@@ -55,7 +55,7 @@ module SimpleForm
|
|
55
55
|
|
56
56
|
def optional(name, options = {}, &block)
|
57
57
|
@options[name] = false
|
58
|
-
use(name, options
|
58
|
+
use(name, options)
|
59
59
|
end
|
60
60
|
|
61
61
|
def wrapper(name, options = nil)
|
@@ -50,6 +50,7 @@ module SimpleForm
|
|
50
50
|
|
51
51
|
def wrap(input, options, content)
|
52
52
|
return content if options[namespace] == false
|
53
|
+
return if defaults[:unless_blank] && content.empty?
|
53
54
|
|
54
55
|
tag = (namespace && options[:"#{namespace}_tag"]) || @defaults[:tag]
|
55
56
|
return content unless tag
|
@@ -42,7 +42,7 @@ class BuilderTest < ActionView::TestCase
|
|
42
42
|
assert_select 'form label.collection_radio_buttons[for=user_active_no]', 'No'
|
43
43
|
end
|
44
44
|
|
45
|
-
test "collection radio
|
45
|
+
test "collection radio sanitizes collection values for labels correctly" do
|
46
46
|
with_collection_radio_buttons @user, :name, ['$0.99', '$1.99'], :to_s, :to_s
|
47
47
|
assert_select 'label.collection_radio_buttons[for=user_name_099]', '$0.99'
|
48
48
|
assert_select 'label.collection_radio_buttons[for=user_name_199]', '$1.99'
|
@@ -289,7 +289,7 @@ class BuilderTest < ActionView::TestCase
|
|
289
289
|
assert_select 'form label.collection_check_boxes[for=user_active_no]', 'No'
|
290
290
|
end
|
291
291
|
|
292
|
-
test "collection check box
|
292
|
+
test "collection check box sanitizes collection values for labels correctly" do
|
293
293
|
with_collection_check_boxes @user, :name, ['$0.99', '$1.99'], :to_s, :to_s
|
294
294
|
assert_select 'label.collection_check_boxes[for=user_name_099]', '$0.99'
|
295
295
|
assert_select 'label.collection_check_boxes[for=user_name_199]', '$1.99'
|
@@ -593,7 +593,7 @@ class BuilderTest < ActionView::TestCase
|
|
593
593
|
end
|
594
594
|
end
|
595
595
|
|
596
|
-
test "fields
|
596
|
+
test "fields inherits wrapper option from the parent form" do
|
597
597
|
swap_wrapper :another do
|
598
598
|
simple_form_for(:user, wrapper: :another) do |f|
|
599
599
|
f.simple_fields_for(:company) do |company|
|