mirror of
https://github.com/heartcombo/simple_form.git
synced 2022-11-09 12:19:26 -05:00
add field_with_hint class to the input with hint wrappers, closes #323
This commit is contained in:
parent
25f8c811d4
commit
40a0b2a7c5
4 changed files with 8 additions and 2 deletions
|
@ -4,7 +4,7 @@ SimpleForm.setup do |config|
|
|||
# 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
|
||||
|
|
|
@ -144,7 +144,7 @@ module SimpleForm
|
|||
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
|
||||
|
|
|
@ -26,6 +26,7 @@ module SimpleForm
|
|||
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
|
||||
|
|
|
@ -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'
|
||||
|
|
Loading…
Reference in a new issue