Class: ActiveScaffold::Config::Form

Inherits:
Base show all
Defined in:
lib/active_scaffold/config/form.rb

Direct Known Subclasses

Create, Update

Instance Attribute Summary collapse

Attributes inherited from Base

#action_group, #user

Instance Method Summary collapse

Methods inherited from Base

#crud_type, #formats, #formats=, inherited, #label

Methods included from ActiveScaffold::Configurable

#configure, #method_missing

Constructor Details

#initialize(core_config) ⇒ Form

Returns a new instance of Form.



3
4
5
6
7
8
9
10
11
12
# File 'lib/active_scaffold/config/form.rb', line 3

def initialize(core_config)
  super
  # 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

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class ActiveScaffold::Configurable

Instance Attribute Details

#label=(value) ⇒ Object (writeonly)

the label for this Form action. used for the header.



29
30
31
# File 'lib/active_scaffold/config/form.rb', line 29

def label=(value)
  @label = value
end

the ActionLink for this action



26
27
28
# File 'lib/active_scaffold/config/form.rb', line 26

def link
  @link
end

#multipart=(value) ⇒ Object (writeonly)

whether the form should be multipart



43
44
45
# File 'lib/active_scaffold/config/form.rb', line 43

def multipart=(value)
  @multipart = value
end

#show_unauthorized_columnsObject

show value of unauthorized columns instead of skip them



23
24
25
# File 'lib/active_scaffold/config/form.rb', line 23

def show_unauthorized_columns
  @show_unauthorized_columns
end

Instance Method Details

#columnsObject

provides access to the list of columns specifically meant for the Form to use



32
33
34
35
36
37
38
# File 'lib/active_scaffold/config/form.rb', line 32

def columns
  unless @columns # lazy evaluation
    self.columns = @core.columns._inheritable
    self.columns.exclude :created_on, :created_at, :updated_on, :updated_at, :marked
  end
  @columns
end

#multipart?Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/active_scaffold/config/form.rb', line 44

def multipart?
  @multipart ? true : false
end