Sha256: e5c3511b5dfb782ff2b8bd554f192f260b36050519ff6de5bb21f1655a4939f4

Contents?: true

Size: 761 Bytes

Versions: 7

Compression:

Stored size: 761 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module Surveys
    module Admin
      # This class holds a Form to update surveys from Decidim's admin panel.
      class SurveyForm < Decidim::Form
        include TranslatableAttributes

        translatable_attribute :title, String
        translatable_attribute :description, String
        translatable_attribute :tos, String

        attribute :published_at, Decidim::Attributes::TimeWithZone
        attribute :questions, Array[SurveyQuestionForm]

        validates :title, :tos, translatable_presence: true

        def map_model(model)
          self.questions = model.questions.map do |question|
            SurveyQuestionForm.from_model(question)
          end
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
decidim-surveys-0.15.2 app/forms/decidim/surveys/admin/survey_form.rb
decidim-surveys-0.15.1 app/forms/decidim/surveys/admin/survey_form.rb
decidim-surveys-0.15.0 app/forms/decidim/surveys/admin/survey_form.rb
decidim-surveys-0.14.4 app/forms/decidim/surveys/admin/survey_form.rb
decidim-surveys-0.14.3 app/forms/decidim/surveys/admin/survey_form.rb
decidim-surveys-0.14.2 app/forms/decidim/surveys/admin/survey_form.rb
decidim-surveys-0.14.1 app/forms/decidim/surveys/admin/survey_form.rb