Sha256: 575376f1bec89ac2a070bc099d2a103e868f67ded410cb2634a157940bb3922a
Contents?: true
Size: 1.08 KB
Versions: 7
Compression:
Stored size: 1.08 KB
Contents
module Para module Component class Form < Para::Component::Resource register :form, self configurable_on :model_type has_one :component_resource, class_name: 'Para::ComponentResource', foreign_key: :component_id, autosave: true, dependent: :destroy def resource build_component_resource(resource: model.new) unless component_resource component_resource.resource ||= model.new end def resource=(value) build_component_resource(resource: value) unless component_resource end def default_form_actions [:submit] end 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 end end end
Version data entries
7 entries across 7 versions & 1 rubygems