From 7cc62836b5d9b6994b12bc9513cf94bbb6a2ff82 Mon Sep 17 00:00:00 2001 From: Go MAEDA Date: Wed, 21 Aug 2024 08:40:04 +0000 Subject: [PATCH] Add placeholder "h:mm" to hours field for better user guidance (#2464). Patch by Go MAEDA (user:maeda). git-svn-id: https://svn.redmine.org/redmine/trunk@22977 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- lib/redmine/views/labelled_form_builder.rb | 1 + test/unit/lib/redmine/views/labelled_form_builder_test.rb | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/redmine/views/labelled_form_builder.rb b/lib/redmine/views/labelled_form_builder.rb index 8c97b8215..f364ca8e2 100644 --- a/lib/redmine/views/labelled_form_builder.rb +++ b/lib/redmine/views/labelled_form_builder.rb @@ -49,6 +49,7 @@ class Redmine::Views::LabelledFormBuilder < ActionView::Helpers::FormBuilder # display the value before type cast when the entered value is not valid if @object.errors[field].blank? options = options.merge(:value => format_hours(@object.send field)) + .with_defaults(:placeholder => 'h:mm') end text_field field, options end diff --git a/test/unit/lib/redmine/views/labelled_form_builder_test.rb b/test/unit/lib/redmine/views/labelled_form_builder_test.rb index ee8529853..11c3409a2 100644 --- a/test/unit/lib/redmine/views/labelled_form_builder_test.rb +++ b/test/unit/lib/redmine/views/labelled_form_builder_test.rb @@ -33,7 +33,9 @@ class Redmine::Views::LabelledFormBuilderTest < Redmine::HelperTest entry.validate labelled_form_for(entry) do |f| - assert_include 'value="2:30"', f.hours_field(:hours) + field_html = f.hours_field(:hours) + assert_include 'value="2:30"', field_html + assert_include 'placeholder="h:mm"', field_html end end -- 2.39.5