Ensure to generate input_class only for the input, not for the wrapper
Thanks @ollym for catching this one. Related to #337.
This commit is contained in:
parent
c14bc3e068
commit
359606f222
|
@ -1,13 +1,14 @@
|
|||
## master
|
||||
|
||||
### enhancements
|
||||
* New `input_class` global config option to set a class to be generated in all inputs.
|
||||
* Collection tags accept html attributes as the last element of collection [@nashby](https://github.com/nashby)
|
||||
* Change default `:value_method` of collection tags from `:last` to `:second` [@nashby](https://github.com/nashby)
|
||||
* Support `Proc` object in `:conditions` option of associations [@bradly](https://github.com/bradly)
|
||||
* `input_field` supports `html5` component [@nashby](https://github.com/nashby)
|
||||
|
||||
### bug fix
|
||||
* Make `DateTimeInput#label_target` method to work with string values in `I18n.t('date.order')` (default
|
||||
* Make `DateTimeInput#label_target` method to work with string values in `I18n.t('date.order')` (default
|
||||
behaviour in Rails 4)
|
||||
Closes [#846](https://github.com/plataformatec/simple_form/issues/846) [@mjankowski](https://github.com/mjankowski)
|
||||
* Add "checkbox" class to the label of boolean input when there is no `:label`
|
||||
|
|
|
@ -65,6 +65,10 @@ module SimpleForm
|
|||
@html_classes = SimpleForm.additional_classes_for(:input) { additional_classes }
|
||||
|
||||
@input_html_classes = @html_classes.dup
|
||||
if SimpleForm.input_class && !input_html_classes.empty?
|
||||
input_html_classes << SimpleForm.input_class
|
||||
end
|
||||
|
||||
@input_html_options = html_options_for(:input, input_html_classes).tap do |o|
|
||||
o[:readonly] = true if has_readonly?
|
||||
o[:disabled] = true if has_disabled?
|
||||
|
@ -81,7 +85,7 @@ module SimpleForm
|
|||
end
|
||||
|
||||
def additional_classes
|
||||
@additional_classes ||= [input_type, required_class, readonly_class, disabled_class, SimpleForm.input_class].compact
|
||||
@additional_classes ||= [input_type, required_class, readonly_class, disabled_class].compact
|
||||
end
|
||||
|
||||
def input_class
|
||||
|
|
|
@ -20,10 +20,19 @@ class InputTest < ActionView::TestCase
|
|||
assert_select 'input.string[autofocus]'
|
||||
end
|
||||
|
||||
test 'input should accepts input class configuration' do
|
||||
swap SimpleForm, :input_class => :xlarge do
|
||||
test 'input accepts input_class configuration' do
|
||||
swap SimpleForm, input_class: :xlarge do
|
||||
with_input_for @user, :name, :string
|
||||
assert_select 'input.xlarge'
|
||||
assert_no_select 'div.xlarge'
|
||||
end
|
||||
end
|
||||
|
||||
test 'input does not add input_class when configured to not generate additional classes for input' do
|
||||
swap SimpleForm, input_class: 'xlarge', generate_additional_classes_for: [:wrapper] do
|
||||
with_input_for @user, :name, :string
|
||||
assert_select 'input'
|
||||
assert_no_select '.xlarge'
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue