Fixes boolean custom fields tags (broken by r1592) (#1640).

git-svn-id: http://redmine.rubyforge.org/svn/trunk@1668 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2008-07-14 17:29:06 +00:00
parent 6d3c0dab01
commit 025581bb28
2 changed files with 6 additions and 1 deletions

View File

@ -37,7 +37,7 @@ module CustomFieldsHelper
when "text" when "text"
text_area_tag(field_name, custom_value.value, :id => field_id, :rows => 3, :style => 'width:90%') text_area_tag(field_name, custom_value.value, :id => field_id, :rows => 3, :style => 'width:90%')
when "bool" 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" when "list"
blank_option = custom_field.is_required? ? blank_option = custom_field.is_required? ?
(custom_field.default_value.blank? ? "<option value=\"\">--- #{l(:actionview_instancetag_blank_option)} ---</option>" : '') : (custom_field.default_value.blank? ? "<option value=\"\">--- #{l(:actionview_instancetag_blank_option)} ---</option>" : '') :

View File

@ -25,6 +25,11 @@ class CustomValue < ActiveRecord::Base
end end
end end
# Returns true if the boolean custom value is true
def true?
self.value == '1'
end
protected protected
def validate def validate
if value.blank? if value.blank?