From cf1f9ff4df3fed98ff61fe9372bc9a2a18212b6a Mon Sep 17 00:00:00 2001 From: Lucas Mazza Date: Tue, 12 Jul 2016 23:19:46 -0300 Subject: [PATCH] Ignore the `:label_text` option when rendering `label` tags. Closes #1314. --- lib/simple_form/form_builder.rb | 2 +- test/form_builder/label_test.rb | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/simple_form/form_builder.rb b/lib/simple_form/form_builder.rb index 2021842e..2f8e171b 100644 --- a/lib/simple_form/form_builder.rb +++ b/lib/simple_form/form_builder.rb @@ -299,7 +299,7 @@ module SimpleForm return super if args.first.is_a?(String) || block_given? options = args.extract_options!.dup - options[:label_html] = options.except(:label, :required, :as) + options[:label_html] = options.except(:label, :label_text, :required, :as) column = find_attribute_column(attribute_name) input_type = default_input_type(attribute_name, column, options) diff --git a/test/form_builder/label_test.rb b/test/form_builder/label_test.rb index bd7ee83f..6503af45 100644 --- a/test/form_builder/label_test.rb +++ b/test/form_builder/label_test.rb @@ -120,4 +120,11 @@ class LabelTest < ActionView::TestCase assert_select 'label[for=user_time_zone]', 'Time Zone:' end end + + test 'builder allows label specific `label_text` option' do + with_label_for @user, :time_zone, label_text: lambda { |l, _, _| "#{l.titleize}:" } + + assert_no_select 'label[label_text]' + assert_select 'label[for=user_time_zone]', 'Time Zone:' + end end