Actions
Bug #1733
closedxmera Omnia - Feature #1736: Support float custom fields to accept user input values considering language conventions
Allow to add and display floating numbers in accordance with the users language
Start date:
Due date:
% Done:
100%
Estimated time:
Affected Version:
Compatible Redmine Version:
Pull Request Link:
Description
Redmine 5.0.5: Custom field format 'Float' does not support values inserted in the users language, e.g., 1,22
instead of 1.22
.
# lib/redmine/field_format.rb:539
def validate_single_value(custom_field, value, customized=nil)
errs = super
errs << ::I18n.t('activerecord.errors.messages.invalid') unless (Kernel.Float(value) rescue nil) # <-- Kernle.Float(value) accepts only 1.22!
errs
end
The values needs to be normalized into the accepted format before it will get validated. The method could look something like this:
def normalize_float(value)
delimiter = I18n::t('number.format.delimiter')
separator = I18n::t('number.format.separator')
value.gsub!(/[#{delimiter}#{separator}]/, delimiter => '', separator => '.')
end
Files
Actions