Class: Para::Component::Form

Inherits:
Resource show all
Includes:
History
Defined in:
app/models/para/component/form.rb

Instance Method Summary collapse

Methods included from History

#history?

Methods inherited from Resource

#model, #model_table_name

Methods inherited from Base

configurable_on, #exportable?, #history?, #main_navigation_name, model_name, #name, register, #subclassable?, #to_param

Methods inherited from ApplicationRecord

with_belongs_to_optional_option_if_needed

Instance Method Details

#default_form_actionsObject



22
23
24
# File 'app/models/para/component/form.rb', line 22

def default_form_actions
  [:submit]
end

#resourceObject



13
14
15
16
# File 'app/models/para/component/form.rb', line 13

def resource
  build_component_resource(resource: model.new) unless component_resource
  component_resource.resource ||= model.new
end

#resource=(value) ⇒ Object



18
19
20
# File 'app/models/para/component/form.rb', line 18

def resource=(value)
  build_component_resource(resource: value) unless component_resource
end

#update_with(attributes) ⇒ Object



26
27
28
29
30
31
32
33
34
35
# File 'app/models/para/component/form.rb', line 26

def update_with(attributes)
  # If no model_type is provided in the configuration file, default to
  # the camelized version of the identifier, allowing to create
  # form components without setting the :model_type option,
  # when given a conventional name
  attributes[:model_type] ||= identifier.to_s.camelize.singularize if identifier
  attributes[:controller] ||= '/para/admin/form_resources'

  super
end