diff --git a/app/helpers/custom_fields_helper.rb b/app/helpers/custom_fields_helper.rb index 540c6b4a1af03413af8d40cd5f1ad51977cf3af3..3c795dc1fea67ba6f6ab505b4dc1948523edbe12 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? ? "<option value=\"\">--- #{l(:actionview_instancetag_blank_option)} ---</option>" : '') : diff --git a/app/models/custom_value.rb b/app/models/custom_value.rb index 98ce6b168617126cd320cc61ab52bf3ed2ce5d53..1d453baf01fb613004bba30bf608a082b14e5d52 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?