From: Jean-Philippe Lang Date: Mon, 14 Jul 2008 17:29:06 +0000 (+0000) Subject: Fixes boolean custom fields tags (broken by r1592) (#1640). X-Git-Tag: 0.8.0-RC1~349 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=025581bb284aa21a83cd9e64e28e3f284489bcfa;p=redmine.git Fixes boolean custom fields tags (broken by r1592) (#1640). git-svn-id: http://redmine.rubyforge.org/svn/trunk@1668 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- diff --git a/app/helpers/custom_fields_helper.rb b/app/helpers/custom_fields_helper.rb index 540c6b4a1..3c795dc1f 100644 --- a/app/helpers/custom_fields_helper.rb +++ b/app/helpers/custom_fields_helper.rb @@ -37,7 +37,7 @@ module CustomFieldsHelper when "text" text_area_tag(field_name, custom_value.value, :id => field_id, :rows => 3, :style => 'width:90%') when "bool" - check_box_tag(field_name, custom_value.value, :id => field_id) + check_box_tag(field_name, '1', custom_value.true?, :id => field_id) + hidden_field_tag(field_name, '0') when "list" blank_option = custom_field.is_required? ? (custom_field.default_value.blank? ? "" : '') : diff --git a/app/models/custom_value.rb b/app/models/custom_value.rb index 98ce6b168..1d453baf0 100644 --- a/app/models/custom_value.rb +++ b/app/models/custom_value.rb @@ -25,6 +25,11 @@ class CustomValue < ActiveRecord::Base end end + # Returns true if the boolean custom value is true + def true? + self.value == '1' + end + protected def validate if value.blank?