simple_form 3.0.2 → 3.1.0.rc2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +35 -32
  3. data/MIT-LICENSE +1 -1
  4. data/README.md +179 -73
  5. data/lib/generators/simple_form/install_generator.rb +2 -2
  6. data/lib/generators/simple_form/templates/README +3 -4
  7. data/lib/generators/simple_form/templates/config/initializers/simple_form.rb +25 -5
  8. data/lib/generators/simple_form/templates/config/initializers/simple_form_bootstrap.rb +108 -24
  9. data/lib/generators/simple_form/templates/config/initializers/simple_form_foundation.rb +1 -1
  10. data/lib/generators/simple_form/templates/config/locales/simple_form.en.yml +7 -2
  11. data/lib/simple_form/action_view_extensions/form_helper.rb +1 -1
  12. data/lib/simple_form/components/errors.rb +30 -2
  13. data/lib/simple_form/components/hints.rb +2 -2
  14. data/lib/simple_form/components/html5.rb +1 -1
  15. data/lib/simple_form/components/label_input.rb +20 -2
  16. data/lib/simple_form/components/labels.rb +10 -6
  17. data/lib/simple_form/components/maxlength.rb +1 -1
  18. data/lib/simple_form/components/min_max.rb +1 -1
  19. data/lib/simple_form/components/pattern.rb +1 -1
  20. data/lib/simple_form/components/placeholders.rb +2 -2
  21. data/lib/simple_form/components/readonly.rb +1 -1
  22. data/lib/simple_form/form_builder.rb +121 -72
  23. data/lib/simple_form/helpers.rb +5 -5
  24. data/lib/simple_form/inputs/base.rb +33 -11
  25. data/lib/simple_form/inputs/block_input.rb +1 -1
  26. data/lib/simple_form/inputs/boolean_input.rb +27 -14
  27. data/lib/simple_form/inputs/collection_input.rb +32 -9
  28. data/lib/simple_form/inputs/collection_radio_buttons_input.rb +6 -11
  29. data/lib/simple_form/inputs/collection_select_input.rb +4 -2
  30. data/lib/simple_form/inputs/date_time_input.rb +12 -2
  31. data/lib/simple_form/inputs/file_input.rb +4 -2
  32. data/lib/simple_form/inputs/grouped_collection_select_input.rb +15 -3
  33. data/lib/simple_form/inputs/hidden_input.rb +4 -2
  34. data/lib/simple_form/inputs/numeric_input.rb +5 -4
  35. data/lib/simple_form/inputs/password_input.rb +4 -2
  36. data/lib/simple_form/inputs/priority_input.rb +4 -2
  37. data/lib/simple_form/inputs/range_input.rb +1 -1
  38. data/lib/simple_form/inputs/string_input.rb +4 -2
  39. data/lib/simple_form/inputs/text_input.rb +4 -2
  40. data/lib/simple_form/railtie.rb +7 -0
  41. data/lib/simple_form/tags.rb +8 -0
  42. data/lib/simple_form/version.rb +1 -1
  43. data/lib/simple_form/wrappers/builder.rb +6 -6
  44. data/lib/simple_form/wrappers/leaf.rb +28 -0
  45. data/lib/simple_form/wrappers/many.rb +6 -6
  46. data/lib/simple_form/wrappers/root.rb +1 -1
  47. data/lib/simple_form/wrappers/single.rb +5 -3
  48. data/lib/simple_form/wrappers.rb +1 -0
  49. data/lib/simple_form.rb +46 -6
  50. data/test/action_view_extensions/builder_test.rb +5 -5
  51. data/test/action_view_extensions/form_helper_test.rb +13 -13
  52. data/test/components/label_test.rb +36 -36
  53. data/test/form_builder/association_test.rb +21 -4
  54. data/test/form_builder/button_test.rb +5 -5
  55. data/test/form_builder/error_notification_test.rb +1 -1
  56. data/test/form_builder/error_test.rb +78 -17
  57. data/test/form_builder/general_test.rb +65 -60
  58. data/test/form_builder/hint_test.rb +15 -15
  59. data/test/form_builder/input_field_test.rb +37 -13
  60. data/test/form_builder/label_test.rb +44 -12
  61. data/test/form_builder/wrapper_test.rb +120 -19
  62. data/test/generators/simple_form_generator_test.rb +2 -2
  63. data/test/inputs/boolean_input_test.rb +54 -6
  64. data/test/inputs/collection_check_boxes_input_test.rb +63 -17
  65. data/test/inputs/collection_radio_buttons_input_test.rb +112 -36
  66. data/test/inputs/collection_select_input_test.rb +141 -36
  67. data/test/inputs/datetime_input_test.rb +116 -49
  68. data/test/inputs/disabled_test.rb +15 -15
  69. data/test/inputs/discovery_test.rb +56 -6
  70. data/test/inputs/file_input_test.rb +2 -2
  71. data/test/inputs/general_test.rb +20 -20
  72. data/test/inputs/grouped_collection_select_input_test.rb +38 -2
  73. data/test/inputs/hidden_input_test.rb +4 -4
  74. data/test/inputs/numeric_input_test.rb +24 -24
  75. data/test/inputs/priority_input_test.rb +7 -7
  76. data/test/inputs/readonly_test.rb +19 -19
  77. data/test/inputs/required_test.rb +13 -13
  78. data/test/inputs/string_input_test.rb +41 -21
  79. data/test/inputs/text_input_test.rb +4 -4
  80. data/test/simple_form_test.rb +8 -0
  81. data/test/support/discovery_inputs.rb +32 -2
  82. data/test/support/misc_helpers.rb +71 -5
  83. data/test/support/models.rb +50 -24
  84. metadata +6 -5
@@ -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 => :lookup`
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 the lookup for any of those
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
@@ -43,6 +43,12 @@ SimpleForm.setup do |config|
43
43
  b.use :label_input
44
44
  b.use :hint, wrap_with: { tag: :span, class: :hint }
45
45
  b.use :error, wrap_with: { tag: :span, class: :error }
46
+
47
+ ## full_messages_for
48
+ # If you want to display the full error message for the attribute, you can
49
+ # use the component :full_error, like:
50
+ #
51
+ # b.use :full_error, wrap_with: { tag: :span, class: :error }
46
52
  end
47
53
 
48
54
  # The default wrapper to be used by the FormBuilder.
@@ -66,7 +72,7 @@ SimpleForm.setup do |config|
66
72
  config.error_notification_tag = :div
67
73
 
68
74
  # CSS class to add for error notification helper.
69
- config.error_notification_class = 'alert alert-error'
75
+ config.error_notification_class = 'error_notification'
70
76
 
71
77
  # ID to add for error notification helper.
72
78
  # config.error_notification_id = nil
@@ -92,10 +98,10 @@ SimpleForm.setup do |config|
92
98
  # config.item_wrapper_class = nil
93
99
 
94
100
  # How the label text should be generated altogether with the required text.
95
- # config.label_text = lambda { |label, required| "#{required} #{label}" }
101
+ # config.label_text = lambda { |label, required, explicit_label| "#{required} #{label}" }
96
102
 
97
103
  # You can define the class to use on all labels. Default is nil.
98
- config.label_class = 'control-label'
104
+ # config.label_class = nil
99
105
 
100
106
  # You can define the class to use on all forms. Default is simple_form.
101
107
  # config.form_class = :simple_form
@@ -125,6 +131,10 @@ SimpleForm.setup do |config|
125
131
  # type as key and the wrapper that will be used for all inputs with specified type.
126
132
  # config.wrapper_mappings = { string: :prepend }
127
133
 
134
+ # Namespaces where SimpleForm should look for custom input classes that
135
+ # override default inputs.
136
+ # config.custom_inputs_namespaces << "CustomInputs"
137
+
128
138
  # Default priority for time_zone inputs.
129
139
  # config.time_zone_priority = nil
130
140
 
@@ -142,4 +152,14 @@ SimpleForm.setup do |config|
142
152
 
143
153
  # Default class for inputs
144
154
  # config.input_class = nil
155
+
156
+ # Define the default class of the input wrapper of the boolean input.
157
+ config.boolean_label_class = 'checkbox'
158
+
159
+ # Defines if the default input wrapper class should be included in radio
160
+ # collection wrappers.
161
+ # config.include_default_input_wrapper_class = true
162
+
163
+ # Defines which i18n scope will be used in Simple Form.
164
+ # config.i18n_scope = 'simple_form'
145
165
  end
@@ -1,45 +1,129 @@
1
1
  # Use this setup block to configure all options available in SimpleForm.
2
2
  SimpleForm.setup do |config|
3
- config.wrappers :bootstrap, tag: 'div', class: 'control-group', error_class: 'error' do |b|
3
+ config.error_notification_class = 'alert alert-danger'
4
+ config.button_class = 'btn btn-default'
5
+ config.boolean_label_class = nil
6
+
7
+ config.wrappers :vertical_form, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
4
8
  b.use :html5
5
9
  b.use :placeholder
6
- b.use :label
7
- b.wrapper tag: 'div', class: 'controls' do |ba|
8
- ba.use :input
9
- ba.use :error, wrap_with: { tag: 'span', class: 'help-inline' }
10
- ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
10
+ b.optional :maxlength
11
+ b.optional :pattern
12
+ b.optional :min_max
13
+ b.optional :readonly
14
+ b.use :label, class: 'control-label'
15
+
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' }
19
+ end
20
+
21
+ config.wrappers :vertical_file_input, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
22
+ b.use :html5
23
+ b.use :placeholder
24
+ b.optional :maxlength
25
+ b.optional :readonly
26
+ b.use :label, class: 'control-label'
27
+
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' }
31
+ end
32
+
33
+ config.wrappers :vertical_boolean, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
34
+ b.use :html5
35
+ b.optional :readonly
36
+
37
+ b.wrapper tag: 'div', class: 'checkbox' do |ba|
38
+ ba.use :label_input
11
39
  end
40
+
41
+ b.use :error, wrap_with: { tag: 'span', class: 'help-block' }
42
+ b.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
43
+ end
44
+
45
+ config.wrappers :vertical_radio_and_checkboxes, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
46
+ b.use :html5
47
+ b.optional :readonly
48
+ b.use :label_input
49
+ b.use :error, wrap_with: { tag: 'span', class: 'help-block' }
50
+ b.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
12
51
  end
13
52
 
14
- config.wrappers :prepend, tag: 'div', class: "control-group", error_class: 'error' do |b|
53
+ config.wrappers :horizontal_form, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
15
54
  b.use :html5
16
55
  b.use :placeholder
17
- b.use :label
18
- b.wrapper tag: 'div', class: 'controls' do |input|
19
- input.wrapper tag: 'div', class: 'input-prepend' do |prepend|
20
- prepend.use :input
21
- end
22
- input.use :hint, wrap_with: { tag: 'span', class: 'help-block' }
23
- input.use :error, wrap_with: { tag: 'span', class: 'help-inline' }
56
+ b.optional :maxlength
57
+ b.optional :pattern
58
+ b.optional :min_max
59
+ b.optional :readonly
60
+ b.use :label, class: 'col-sm-3 control-label'
61
+
62
+ b.wrapper tag: 'div', class: 'col-sm-9' do |ba|
63
+ ba.use :input, class: 'form-control'
64
+ ba.use :error, wrap_with: { tag: 'span', class: 'help-block' }
65
+ ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
24
66
  end
25
67
  end
26
68
 
27
- config.wrappers :append, tag: 'div', class: "control-group", error_class: 'error' do |b|
69
+ config.wrappers :horizontal_file_input, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
28
70
  b.use :html5
29
71
  b.use :placeholder
30
- b.use :label
31
- b.wrapper tag: 'div', class: 'controls' do |input|
32
- input.wrapper tag: 'div', class: 'input-append' do |append|
33
- append.use :input
72
+ b.optional :maxlength
73
+ b.optional :readonly
74
+ b.use :label, class: 'col-sm-3 control-label'
75
+
76
+ b.wrapper tag: 'div', class: 'col-sm-9' do |ba|
77
+ ba.use :input
78
+ ba.use :error, wrap_with: { tag: 'span', class: 'help-block' }
79
+ ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
80
+ end
81
+ end
82
+
83
+ config.wrappers :horizontal_boolean, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
84
+ b.use :html5
85
+ b.optional :readonly
86
+
87
+ b.wrapper tag: 'div', class: 'col-sm-offset-3 col-sm-9' do |wr|
88
+ wr.wrapper tag: 'div', class: 'checkbox' do |ba|
89
+ ba.use :label_input, class: 'col-sm-9'
34
90
  end
35
- input.use :hint, wrap_with: { tag: 'span', class: 'help-block' }
36
- input.use :error, wrap_with: { tag: 'span', class: 'help-inline' }
91
+
92
+ wr.use :error, wrap_with: { tag: 'span', class: 'help-block' }
93
+ wr.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
37
94
  end
38
95
  end
39
96
 
40
- # Wrappers for forms and inputs using the Twitter Bootstrap toolkit.
41
- # Check the Bootstrap docs (http://twitter.github.com/bootstrap)
97
+ config.wrappers :horizontal_radio_and_checkboxes, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
98
+ b.use :html5
99
+ b.optional :readonly
100
+
101
+ b.use :label, class: 'col-sm-3 control-label'
102
+
103
+ b.wrapper tag: 'div', class: 'col-sm-9' do |ba|
104
+ ba.use :input
105
+ ba.use :error, wrap_with: { tag: 'span', class: 'help-block' }
106
+ ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
107
+ end
108
+ end
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
+
124
+ # Wrappers for forms and inputs using the Bootstrap toolkit.
125
+ # Check the Bootstrap docs (http://getbootstrap.com)
42
126
  # to learn about the different styles for forms and inputs,
43
127
  # buttons and other elements.
44
- config.default_wrapper = :bootstrap
128
+ config.default_wrapper = :vertical_form
45
129
  end
@@ -8,7 +8,7 @@ SimpleForm.setup do |config|
8
8
  b.optional :min_max
9
9
  b.optional :readonly
10
10
  b.use :label_input
11
- b.use :error, wrap_with: { tag: :small }
11
+ b.use :error, wrap_with: { tag: :small, class: :error }
12
12
 
13
13
  # Uncomment the following line to enable hints. The line is commented out by default since Foundation
14
14
  # does't provide styles for hints. You will need to provide your own CSS styles for hints.
@@ -10,7 +10,7 @@ en:
10
10
  # html: '<abbr title="required">*</abbr>'
11
11
  error_notification:
12
12
  default_message: "Please review the problems below:"
13
- # Labels and hints examples
13
+ # Examples
14
14
  # labels:
15
15
  # defaults:
16
16
  # password: 'Password'
@@ -23,4 +23,9 @@ en:
23
23
  # defaults:
24
24
  # username: 'User name to sign in.'
25
25
  # password: 'No special characters, please.'
26
-
26
+ # include_blanks:
27
+ # defaults:
28
+ # age: 'Rather not say'
29
+ # prompts:
30
+ # defaults:
31
+ # age: 'Select your age'
@@ -10,7 +10,7 @@ module SimpleForm
10
10
  #
11
11
  module FormHelper
12
12
 
13
- def simple_form_for(record, options={}, &block)
13
+ def simple_form_for(record, options = {}, &block)
14
14
  options[:builder] ||= SimpleForm::FormBuilder
15
15
  options[:html] ||= {}
16
16
  unless options[:html].key?(:novalidate)
@@ -1,10 +1,14 @@
1
1
  module SimpleForm
2
2
  module Components
3
3
  module Errors
4
- def error
4
+ def error(wrapper_options = nil)
5
5
  error_text if has_errors?
6
6
  end
7
7
 
8
+ def full_error(wrapper_options = nil)
9
+ full_error_text if options[:error] != false && has_errors?
10
+ end
11
+
8
12
  def has_errors?
9
13
  object && object.respond_to?(:errors) && errors.present?
10
14
  end
@@ -12,7 +16,15 @@ module SimpleForm
12
16
  protected
13
17
 
14
18
  def error_text
15
- "#{html_escape(options[:error_prefix])} #{errors.send(error_method)}".lstrip.html_safe
19
+ text = has_custom_error? ? options[:error] : errors.send(error_method)
20
+
21
+ "#{html_escape(options[:error_prefix])} #{text}".lstrip.html_safe
22
+ end
23
+
24
+ def full_error_text
25
+ text = has_custom_error? ? options[:error] : full_errors.send(error_method)
26
+
27
+ text.html_safe
16
28
  end
17
29
 
18
30
  def error_method
@@ -23,13 +35,29 @@ module SimpleForm
23
35
  @errors ||= (errors_on_attribute + errors_on_association).compact
24
36
  end
25
37
 
38
+ def full_errors
39
+ @full_errors ||= (full_errors_on_attribute + full_errors_on_association).compact
40
+ end
41
+
26
42
  def errors_on_attribute
27
43
  object.errors[attribute_name]
28
44
  end
29
45
 
46
+ def full_errors_on_attribute
47
+ object.errors.full_messages_for(attribute_name)
48
+ end
49
+
30
50
  def errors_on_association
31
51
  reflection ? object.errors[reflection.name] : []
32
52
  end
53
+
54
+ def full_errors_on_association
55
+ reflection ? object.full_messages_for(reflection.name) : []
56
+ end
57
+
58
+ def has_custom_error?
59
+ options[:error].is_a?(String)
60
+ end
33
61
  end
34
62
  end
35
63
  end
@@ -2,14 +2,14 @@ module SimpleForm
2
2
  module Components
3
3
  # Needs to be enabled in order to do automatic lookups.
4
4
  module Hints
5
- def hint
5
+ def hint(wrapper_options = nil)
6
6
  @hint ||= begin
7
7
  hint = options[:hint]
8
8
 
9
9
  if hint.is_a?(String)
10
10
  html_escape(hint)
11
11
  else
12
- content = translate(:hints)
12
+ content = translate_from_namespace(:hints)
13
13
  content.html_safe if content
14
14
  end
15
15
  end
@@ -5,7 +5,7 @@ module SimpleForm
5
5
  @html5 = false
6
6
  end
7
7
 
8
- def html5
8
+ def html5(wrapper_options = nil)
9
9
  @html5 = true
10
10
  if has_required?
11
11
  input_html_options[:required] = true
@@ -7,8 +7,26 @@ module SimpleForm
7
7
  include SimpleForm::Components::Labels
8
8
  end
9
9
 
10
- def label_input
11
- options[:label] == false ? input : (label + input)
10
+ def label_input(wrapper_options = nil)
11
+ if options[:label] == false
12
+ deprecated_component(:input, wrapper_options)
13
+ else
14
+ deprecated_component(:label, wrapper_options) + deprecated_component(:input, wrapper_options)
15
+ end
16
+ end
17
+
18
+ private
19
+
20
+ def deprecated_component(namespace, wrapper_options)
21
+ method = method(namespace)
22
+
23
+ if method.arity == 0
24
+ ActiveSupport::Deprecation.warn(SimpleForm::CUSTOM_INPUT_DEPRECATION_WARN % { name: namespace })
25
+
26
+ method.call
27
+ else
28
+ method.call(wrapper_options)
29
+ end
12
30
  end
13
31
  end
14
32
  end
@@ -21,16 +21,19 @@ module SimpleForm
21
21
  end
22
22
  end
23
23
 
24
- def label
24
+ def label(wrapper_options = nil)
25
+ label_options = merge_wrapper_options(label_html_options, wrapper_options)
26
+
25
27
  if generate_label_for_attribute?
26
- @builder.label(label_target, label_text, label_html_options)
28
+ @builder.label(label_target, label_text, label_options)
27
29
  else
28
- template.label_tag(nil, label_text, label_html_options)
30
+ template.label_tag(nil, label_text, label_options)
29
31
  end
30
32
  end
31
33
 
32
- def label_text
33
- SimpleForm.label_text.call(html_escape(raw_label_text), required_label_text).strip.html_safe
34
+ def label_text(wrapper_options = nil)
35
+ label_text = options[:label_text] || SimpleForm.label_text
36
+ label_text.call(html_escape(raw_label_text), required_label_text, options[:label].present?).strip.html_safe
34
37
  end
35
38
 
36
39
  def label_target
@@ -46,6 +49,7 @@ module SimpleForm
46
49
  if options.key?(:input_html) && options[:input_html].key?(:id)
47
50
  label_options[:for] = options[:input_html][:id]
48
51
  end
52
+
49
53
  label_options
50
54
  end
51
55
 
@@ -62,7 +66,7 @@ module SimpleForm
62
66
 
63
67
  # First check labels translation and then human attribute name.
64
68
  def label_translation #:nodoc:
65
- if SimpleForm.translate_labels && (translated_label = translate(:labels))
69
+ if SimpleForm.translate_labels && (translated_label = translate_from_namespace(:labels))
66
70
  translated_label
67
71
  elsif object.class.respond_to?(:human_attribute_name)
68
72
  object.class.human_attribute_name(reflection_or_attribute_name.to_s)
@@ -2,7 +2,7 @@ module SimpleForm
2
2
  module Components
3
3
  # Needs to be enabled in order to do automatic lookups.
4
4
  module Maxlength
5
- def maxlength
5
+ def maxlength(wrapper_options = nil)
6
6
  input_html_options[:maxlength] ||= maximum_length_from_validation || limit
7
7
  nil
8
8
  end
@@ -1,7 +1,7 @@
1
1
  module SimpleForm
2
2
  module Components
3
3
  module MinMax
4
- def min_max
4
+ def min_max(wrapper_options = nil)
5
5
  if numeric_validator = find_numericality_validator
6
6
  validator_options = numeric_validator.options
7
7
  input_html_options[:min] ||= minimum_value(validator_options)
@@ -2,7 +2,7 @@ module SimpleForm
2
2
  module Components
3
3
  # Needs to be enabled in order to do automatic lookups.
4
4
  module Pattern
5
- def pattern
5
+ def pattern(wrapper_options = nil)
6
6
  input_html_options[:pattern] ||= pattern_source
7
7
  nil
8
8
  end
@@ -2,14 +2,14 @@ module SimpleForm
2
2
  module Components
3
3
  # Needs to be enabled in order to do automatic lookups.
4
4
  module Placeholders
5
- def placeholder
5
+ def placeholder(wrapper_options = nil)
6
6
  input_html_options[:placeholder] ||= placeholder_text
7
7
  nil
8
8
  end
9
9
 
10
10
  def placeholder_text
11
11
  placeholder = options[:placeholder]
12
- placeholder.is_a?(String) ? placeholder : translate(:placeholders)
12
+ placeholder.is_a?(String) ? placeholder : translate_from_namespace(:placeholders)
13
13
  end
14
14
  end
15
15
  end
@@ -2,7 +2,7 @@ module SimpleForm
2
2
  module Components
3
3
  # Needs to be enabled in order to do automatic lookups.
4
4
  module Readonly
5
- def readonly
5
+ def readonly(wrapper_options = nil)
6
6
  if readonly_attribute? && !has_readonly?
7
7
  input_html_options[:readonly] ||= true
8
8
  input_html_classes << :readonly