Defect #12146 » 11_correct_bug_with_required_cf_with_multiple_values.patch
| app\models\issue.rb 2013-09-18 09:33:10.000000000 +0200 | ||
|---|---|---|
| 581 | 581 |
user = new_record? ? author : current_journal.try(:user) |
| 582 | 582 |
|
| 583 | 583 |
required_attribute_names(user).each do |attribute| |
| 584 | 584 |
if attribute =~ /^\d+$/ |
| 585 | 585 |
attribute = attribute.to_i |
| 586 | 586 |
v = custom_field_values.detect {|v| v.custom_field_id == attribute }
|
| 587 |
if v && v.value.blank? |
|
| 588 |
errors.add :base, v.custom_field.name + ' ' + l('activerecord.errors.messages.blank')
|
|
| 587 |
if v |
|
| 588 |
if v.value.is_a?(Array) |
|
| 589 |
if ((v.value.count == 0) || ((v.value.count == 1) && (v.value[0] == ""))) |
|
| 590 |
errors.add :base, v.custom_field.name + ' ' + l('activerecord.errors.messages.blank')
|
|
| 591 |
end |
|
| 592 |
else |
|
| 593 |
if v.value.blank? |
|
| 594 |
errors.add :base, v.custom_field.name + ' ' + l('activerecord.errors.messages.blank')
|
|
| 595 |
end |
|
| 596 |
end |
|
| 589 | 597 |
end |
| 590 | 598 |
else |
| 591 | 599 |
if respond_to?(attribute) && send(attribute).blank? |
| 592 | 600 |
errors.add attribute, :blank |
| 593 | 601 |
end |
| 594 | 602 |
end |