Class: Decidim::Plans::ContentForm

Inherits:
Form
  • Object
show all
Includes:
OptionallyTranslatableAttributes, TranslationsHelper
Defined in:
app/forms/decidim/plans/content_form.rb

Overview

A form object to be used when admin users want to create or edit a plan content field.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from OptionallyTranslatableAttributes

#before_validation

Instance Attribute Details

#planObject



30
31
32
# File 'app/forms/decidim/plans/content_form.rb', line 30

def plan
  @plan ||= Decidim::Plans::Plan.find(plan_id)
end

#sectionObject



26
27
28
# File 'app/forms/decidim/plans/content_form.rb', line 26

def section
  @section ||= Decidim::Plans::Section.find(section_id)
end

Instance Method Details

#deleted?Boolean

Returns:

  • (Boolean)


53
54
55
# File 'app/forms/decidim/plans/content_form.rb', line 53

def deleted?
  false
end

#helpObject



38
39
40
# File 'app/forms/decidim/plans/content_form.rb', line 38

def help
  translated_attribute(section.help)
end

#labelObject



34
35
36
# File 'app/forms/decidim/plans/content_form.rb', line 34

def label
  translated_attribute(section.body)
end

#map_model(model) ⇒ Object

Public: Map the correct fields.

Returns nothing.



45
46
47
48
49
50
51
# File 'app/forms/decidim/plans/content_form.rb', line 45

def map_model(model)
  self.section_id = model.decidim_section_id
  self.section = model.section

  self.plan_id = model.decidim_plan_id
  self.plan = model.plan
end