Skip to content

Commit

Permalink
Fix to missing check for required
Browse files Browse the repository at this point in the history
  • Loading branch information
cykod committed May 26, 2011
1 parent 7f72e63 commit 0ec5390
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion app/models/content/field.rb
Expand Up @@ -123,7 +123,7 @@ def set_field_options(options)

@@setup_model_procs = {
:required => Proc.new { |cls,fld| cls.validates_presence_of fld.model_field.field if fld.model_field.field_options['required'] },
:required_array => Proc.new { |cls,fld| cls.validate { |mdl| mdl.errors.add(fld.model_field.field, 'is missing') if mdl.send(fld.model_field.field) && mdl.send(fld.model_field.field).reject(&:blank?).length == 0 } },
:required_array => Proc.new { |cls,fld| cls.validate { |mdl| mdl.errors.add(fld.model_field.field, 'is missing') if options['required'] && mdl.send(fld.model_field.field) && mdl.send(fld.model_field.field).reject(&:blank?).length == 0 } },
:unique => Proc.new { |cls,fld| cls.validates_uniqueness_of fld.model_field.field, :allow_blank => true if fld.model_field.field_options['unique'] },
:regexp => Proc.new { |cls,fld| cls.validates_format_of fld.model_field.field, :with => Regexp.new(fld.model_field.field_options['regexp_code']), :message => fld.model_field.field_options['regexp_message'].to_s, :allow_blank => true if fld.model_field.field_options['regexp'] },
:validates_as_email => Proc.new { |cls,fld| cls.validates_as_email fld.model_field.field },
Expand Down

0 comments on commit 0ec5390

Please sign in to comment.