Sha256: d2defaf0fca927fcf1e9ac04b7b77014bb97e4e9cebf6ab6a281d82ebc39004e

Contents?: true

Size: 692 Bytes

Versions: 15

Compression:

Stored size: 692 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, :required => true

    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

15 entries across 15 versions & 1 rubygems

Version Path
noodall-form-builder-0.2.11 app/models/noodall/field.rb
noodall-form-builder-0.2.10 app/models/noodall/field.rb
noodall-form-builder-0.2.9 app/models/noodall/field.rb
noodall-form-builder-0.2.8 app/models/noodall/field.rb
noodall-form-builder-0.2.7 app/models/noodall/field.rb
noodall-form-builder-0.2.5 app/models/noodall/field.rb
noodall-form-builder-0.2.4 app/models/noodall/field.rb
noodall-form-builder-0.2.3 app/models/noodall/field.rb
noodall-form-builder-0.2.2 app/models/noodall/field.rb
noodall-form-builder-0.2.1 app/models/noodall/field.rb
noodall-form-builder-0.2.0 app/models/noodall/field.rb
noodall-form-builder-0.1.3 app/models/noodall/field.rb
noodall-form-builder-0.1.2 app/models/noodall/field.rb
noodall-form-builder-0.1.1 app/models/noodall/field.rb
noodall-form-builder-0.1.0 app/models/noodall/field.rb