Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

add field_with_hint class to the input with hint wrappers, closes #323

  • Loading branch information...
commit 40a0b2a7c53328f02f953371dda1e59f6e0ce7d7 1 parent 25f8c81
@nashby authored
View
2  lib/generators/simple_form/templates/config/initializers/simple_form.rb
@@ -4,7 +4,7 @@
# You can remove any component from the wrapper, change the order or even
# add your own to the stack. The options given to the wrappers method
# are used to wrap the whole input.
- config.wrappers :class => :input, :error_class => :field_with_errors do |b|
+ config.wrappers :class => :input, :hint_class => :field_with_hint, :error_class => :field_with_errors do |b|
## Extensions
# Determines whether to use HTML5 (:email, :url, :search, :tel) and required attributes
b.use :html5
View
2  lib/simple_form.rb
@@ -144,7 +144,7 @@ def self.build(options={})
SimpleForm::Wrappers::Root.new(builder.to_a, options)
end
- wrappers :class => :input, :error_class => :field_with_errors do |b|
+ wrappers :class => :input, :hint_class => :field_with_hint, :error_class => :field_with_errors do |b|
b.use :html5
b.use :min_max
View
1  lib/simple_form/wrappers/root.rb
@@ -26,6 +26,7 @@ def html_classes(input, options)
css = options[:wrapper_class] ? Array.wrap(options[:wrapper_class]) : @defaults[:class]
css += input.html_classes
css << (options[:wrapper_error_class] || @defaults[:error_class]) if input.has_errors?
+ css << (options[:wrapper_hint_class] || @defaults[:hint_class]) if input.hint
css
end
end
View
5 test/form_builder/wrapper_test.rb
@@ -16,6 +16,11 @@ class WrapperTest < ActionView::TestCase
assert_select 'div.field_with_errors'
end
+ test 'wrapper should add hint class for attribute with a hint' do
+ with_form_for @user, :name, :hint => 'hint'
+ assert_select 'div.field_with_hint'
+ end
+
test 'wrapper should not have disabled class by default' do
with_form_for @user, :active
assert_no_select 'div.disabled'
Please sign in to comment.
Something went wrong with that request. Please try again.