Defect #18654

Custom field is rendered, even if its value is empty (for multiple)

Added by Andriy Lesyuk over 3 years ago. Updated over 3 years ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:Jean-Philippe Lang% Done:

0%

Category:Custom fields
Target version:3.0.0
Resolution:Fixed Affected version:2.6.0

Description

Redmine checks, if the value is available for the custom field, as follows:

if custom_value.value.present?

But for multiple custom fields (e.g., lists, that allow selecting multiple values), the original nil value is replaced with [nil] (not sure where exactly). So, [nil].empty? returns false and the custom field gets rendered.

This issue affects 3.0.x and 1.4.x versions of Redmine.

P.S. Can be solved by montkey-patching `CustomFieldValue` as follows:

alias_method_chain :value, :extended

...

def value_with_extended
    value = value_without_extended
    if custom_field.multiple? && value.present? && value.size == 1 && value.first.nil?
        nil
    else
        value
    end
end

Related issues

Related to Redmine - Defect #19482: Custom field (long text format) displayed even if empty Closed

Associated revisions

Revision 13864
Added by Jean-Philippe Lang over 3 years ago

Fixed: Custom field is rendered, even if its value is empty (for multiple) (#18654).

History

#1 Updated by Jean-Philippe Lang over 3 years ago

  • Assignee set to Jean-Philippe Lang
  • Target version set to 3.0.0

#2 Updated by Jean-Philippe Lang over 3 years ago

  • Status changed from New to Closed
  • Resolution set to Fixed

Fixed in r13864, thanks for pointing this out.

#3 Updated by Toshi MARUYAMA about 3 years ago

  • Related to Defect #19482: Custom field (long text format) displayed even if empty added

Also available in: Atom PDF