From 8787bfe3174f7683262a943c73de95172e0de727 Mon Sep 17 00:00:00 2001 From: Florian Bogenhard Date: Fri, 24 Apr 2015 16:52:35 +0200 Subject: [PATCH] Fixed label for bug with specified id - #213 --- CHANGELOG.md | 1 + lib/bootstrap_form/form_builder.rb | 2 +- test/bootstrap_form_group_test.rb | 7 ++++++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 096aff677..3669ce47d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ Bugfixes: - Minor README corrections (#184, @msmithstubbs) + - Fixed label for bug with specified id (#213, #221, @datWav) Features: diff --git a/lib/bootstrap_form/form_builder.rb b/lib/bootstrap_form/form_builder.rb index 00ca86449..f4bc81c99 100644 --- a/lib/bootstrap_form/form_builder.rb +++ b/lib/bootstrap_form/form_builder.rb @@ -334,7 +334,7 @@ def convert_form_tag_options(method, options = {}) end def generate_label(id, name, options, custom_label_col, group_layout) - options[:for] = id if acts_like_form_tag + options[:for] = id if acts_like_form_tag || !id.nil? classes = [options[:class], label_class] classes << (custom_label_col || label_col) if get_group_layout(group_layout) == :horizontal classes << "required" if required_attribute?(object, name) diff --git a/test/bootstrap_form_group_test.rb b/test/bootstrap_form_group_test.rb index 8369b6f53..bcd3e67a0 100644 --- a/test/bootstrap_form_group_test.rb +++ b/test/bootstrap_form_group_test.rb @@ -27,6 +27,11 @@ def setup assert_equal expected, @builder.text_field(:email, skip_label: true) end + test "change label for attribute with specified id" do + expected = %{
} + assert_equal expected, @builder.text_field(:email, id: 'blabla_blub') + end + test "adding prepend text" do expected = %{
@
} assert_equal expected, @builder.text_field(:email, prepend: '@') @@ -252,5 +257,5 @@ def setup expected = %{

Bar

} assert_equal expected, output - end + end end