Sha256: f5d8cf607354fec8179d63ba48188e2320a5f7a41309e15a259eade84351f83f
Contents?: true
Size: 1.26 KB
Versions: 16
Compression:
Stored size: 1.26 KB
Contents
# frozen_string_literal: true module Decidim module Plans # A form object to be used when admin users want to create or edit # a plan content field. class ContentForm < Decidim::Form include OptionallyTranslatableAttributes include Decidim::TranslationsHelper mimic :content alias component current_component optionally_translatable_attribute :body, String attribute :section_id, Integer attribute :plan_id, Integer optionally_translatable_validate_presence :body, if: :mandatory attr_writer :section attr_writer :plan delegate :mandatory, to: :section def section @section ||= Decidim::Plans::Section.find(section_id) end def plan @plan ||= Decidim::Plans::Plan.find(plan_id) end def label translated_attribute(section.body) end def help translated_attribute(section.help) end # Public: Map the correct fields. # # Returns nothing. 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 def deleted? false end end end end
Version data entries
16 entries across 16 versions & 1 rubygems