Sha256: 7ce0d6e54f9988e7dc189f49ab2cba651bd854ba94bde5efdb8f87a0d824a031

Contents?: true

Size: 1.6 KB

Versions: 7

Compression:

Stored size: 1.6 KB

Contents

module ActiveScaffold::Config
  class Form < Base
    def initialize(core_config)
      @core = core_config

      # start with the ActionLink defined globally
      @link = self.class.link.clone unless self.class.link.nil?
      @action_group = self.class.action_group.clone if self.class.action_group
      @show_unauthorized_columns = self.class.show_unauthorized_columns

      # no global setting here because multipart should only be set for specific forms
      @multipart = false
    end

    # global level configuration
    # --------------------------
    # show value of unauthorized columns instead of skip them
    class_inheritable_accessor :show_unauthorized_columns

    # instance-level configuration
    # ----------------------------

    # show value of unauthorized columns instead of skip them
    attr_accessor :show_unauthorized_columns
    
    # the ActionLink for this action
    attr_accessor :link

    # the label for this Form action. used for the header.
    attr_writer :label
    def label
      as_(@label)
    end

    # provides access to the list of columns specifically meant for the Form to use
    def columns
      unless @columns # lazy evaluation
        self.columns = @core.columns._inheritable
        self.columns.exclude :created_on, :created_at, :updated_on, :updated_at, :marked
        self.columns.exclude *@core.columns.collect{|c| c.name if c.polymorphic_association?}.compact
      end
      @columns
    end
    
    public :columns=
    
    # whether the form should be multipart
    attr_writer :multipart
    def multipart?
      @multipart ? true : false
    end
  end
end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
active_scaffold-3.0.26 lib/active_scaffold/config/form.rb
active_scaffold-3.0.25 lib/active_scaffold/config/form.rb
active_scaffold_clarity-3.0.24.2 lib/active_scaffold/config/form.rb
active_scaffold-3.0.24 lib/active_scaffold/config/form.rb
active_scaffold-3.0.23 lib/active_scaffold/config/form.rb
active_scaffold-3.0.22 lib/active_scaffold/config/form.rb
active_scaffold-3.0.21 lib/active_scaffold/config/form.rb