Class: Form::Field

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
Admin::Form::Field
Defined in:
app/models/form/field.rb

Instance Method Summary collapse

Methods included from Admin::Form::Field

#rails_admin_label

Instance Method Details

#column_keyObject



34
35
36
# File 'app/models/form/field.rb', line 34

def column_key
  :"column_#{position}"
end

#default_labelObject



42
43
44
# File 'app/models/form/field.rb', line 42

def default_label
  send("label_#{I18n.default_locale}")
end

#input_typeObject



46
47
48
# File 'app/models/form/field.rb', line 46

def input_type
  type.demodulize.underscore.to_sym
end

#labelObject



38
39
40
# File 'app/models/form/field.rb', line 38

def label
  send("label_#{I18n.locale}")
end

#type_enumObject



50
51
52
# File 'app/models/form/field.rb', line 50

def type_enum
  TYPES
end

#update_headerObject



54
55
56
57
58
59
60
61
62
63
64
# File 'app/models/form/field.rb', line 54

def update_header
  attributes = RailsAdminCMS::Config.custom_form_max_size.times.map do |i|
    [:"column_#{i}", '']
  end.to_h

  fields.map do |field|
    attributes[field.column_key] = field.default_label
  end

  header.update! attributes
end