Project

General

Profile

Actions

Bug #1733

closed

xmera 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

Added by liaham over 1 year ago. Updated over 1 year ago.

Status:
Closed
Priority:
Normal
Assignee:
Target version:
-
Start date:
Due date:
% Done:

100%

Estimated time:
Affected Version:
Compatible Redmine Version:

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 #1

Updated by liaham over 1 year ago

  • Description updated (diff)
Actions #2

Updated by liaham over 1 year ago

  • Subject changed from Allow to add floating numbers in accordance with the users language to Allow to add and display floating numbers in accordance with the users language
Actions #4

Updated by liaham over 1 year ago

  • Parent task set to #1736
Actions #5

Updated by liaham over 1 year ago

  • Status changed from New to Closed
  • Assignee set to liaham
  • % Done changed from 0 to 100

See redmine.org issue #22024.

Integrated as patch file.

Actions #6

Updated by liaham over 1 year ago

The patch has changed! It is not yet commited to redmine.org.

Actions

Also available in: Atom PDF