Added default value for custom fields. Fixed javascript on custom field form for project and user custom fields.

git-svn-id: http://redmine.rubyforge.org/svn/trunk@1090 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang
2008-01-20 21:29:51 +00:00
parent 59c5d995c3
commit d6bfb7fa4d
29 changed files with 96 additions and 12 deletions
+6
View File
@@ -19,6 +19,12 @@ class CustomValue < ActiveRecord::Base
belongs_to :custom_field
belongs_to :customized, :polymorphic => true
def after_initialize
if custom_field && new_record? && (customized_type.blank? || (customized && customized.new_record?))
self.value ||= custom_field.default_value
end
end
protected
def validate
errors.add(:value, :activerecord_error_blank) and return if custom_field.is_required? and value.blank?