Sha256: 3638e3f5338c27111f34d1bc763912cc989fcb30b59b9a270058341010441bb6

Contents?: true

Size: 673 Bytes

Versions: 7

Compression:

Stored size: 673 Bytes

Contents

module  Noodall
  class Field
    include MongoMapper::EmbeddedDocument

    key :_type, String, :required => true
    key :name, String, :required => true
    key :label, String
    key :default, String
    key :required, Boolean, :default => false

    embedded_in :form

    before_save :default_label
    def default_label
      self.label = self.name if self.label.blank?
    end
    
    def underscored_name
      name.parameterize.gsub('-','_').to_s
    end
    
    def default_class(response)
      'default-value' if response.send(underscored_name.to_sym) == default
    end

    def mandatory?
      Form::MANDATORY_FIELDS.include?(self.name)
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
noodall-form-builder-0.4.2 app/models/noodall/field.rb
noodall-form-builder-0.4.1 app/models/noodall/field.rb
noodall-form-builder-0.4.0 app/models/noodall/field.rb
noodall-form-builder-0.3.3 app/models/noodall/field.rb
noodall-form-builder-0.3.2 app/models/noodall/field.rb
noodall-form-builder-0.3.1 app/models/noodall/field.rb
noodall-form-builder-0.3.0 app/models/noodall/field.rb