mirror of
https://github.com/heartcombo/simple_form.git
synced 2022-11-09 12:19:26 -05:00
Add disabled class to label's additional classes
Adds disabled class to the attribute label so that it might also be styled when the input is disabled
This commit is contained in:
parent
b2516e717b
commit
31841186f0
2 changed files with 11 additions and 1 deletions
|
@ -42,7 +42,7 @@ module SimpleForm
|
|||
|
||||
def label_html_options
|
||||
label_html_classes = SimpleForm.additional_classes_for(:label) {
|
||||
[input_type, required_class, SimpleForm.label_class].compact
|
||||
[input_type, required_class, disabled_class, SimpleForm.label_class].compact
|
||||
}
|
||||
|
||||
label_options = html_options_for(:label, label_html_classes)
|
||||
|
|
|
@ -29,6 +29,16 @@ class LabelTest < ActionView::TestCase
|
|||
assert_select 'label.string.required[for=validating_user_name]', /Name/
|
||||
end
|
||||
|
||||
test 'builder adds a disabled class to label if the attribute is disabled' do
|
||||
with_label_for @validating_user, :name, disabled: true
|
||||
assert_select 'label.string.disabled[for=validating_user_name]', /Name/
|
||||
end
|
||||
|
||||
test 'builder does not add a disabled class to label if the attribute is not disabled' do
|
||||
with_label_for @validating_user, :name, disabled: false
|
||||
assert_no_select 'label.string.disabled[for=validating_user_name]', /Name/
|
||||
end
|
||||
|
||||
test 'builder escapes label text' do
|
||||
with_label_for @user, :name, label: '<script>alert(1337)</script>', required: false
|
||||
assert_no_select 'label.string script'
|
||||
|
|
Loading…
Reference in a new issue