Sha256: abd2ce525274eb2e673196b3b5fd935cbf02e12b931916c2a4cd14b853cd0643

Contents?: true

Size: 806 Bytes

Versions: 51

Compression:

Stored size: 806 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module Consultations
    module Admin
      # A form object used to create questions for a consultation from the admin dashboard.
      class QuestionConfigurationForm < Form
        include TranslatableAttributes
        mimic :question

        attribute :max_votes, Integer, default: 1
        attribute :min_votes, Integer, default: 1
        translatable_attribute :instructions, String

        validates :max_votes, numericality: { greater_than_or_equal_to: 1 }
        validates :min_votes, numericality: { greater_than_or_equal_to: 1 }
        validate :min_lower_than_max

        def min_lower_than_max
          return if min_votes.to_i <= max_votes.to_i

          errors.add(:max_votes, :lower_than_min)
        end
      end
    end
  end
end

Version data entries

51 entries across 51 versions & 1 rubygems

Version Path
decidim-consultations-0.27.9 app/forms/decidim/consultations/admin/question_configuration_form.rb
decidim-consultations-0.27.8 app/forms/decidim/consultations/admin/question_configuration_form.rb
decidim-consultations-0.27.7 app/forms/decidim/consultations/admin/question_configuration_form.rb
decidim-consultations-0.27.6 app/forms/decidim/consultations/admin/question_configuration_form.rb
decidim-consultations-0.26.10 app/forms/decidim/consultations/admin/question_configuration_form.rb
decidim-consultations-0.26.9 app/forms/decidim/consultations/admin/question_configuration_form.rb
decidim-consultations-0.27.5 app/forms/decidim/consultations/admin/question_configuration_form.rb
decidim-consultations-0.26.8 app/forms/decidim/consultations/admin/question_configuration_form.rb
decidim-consultations-0.27.4 app/forms/decidim/consultations/admin/question_configuration_form.rb
decidim-consultations-0.27.3 app/forms/decidim/consultations/admin/question_configuration_form.rb
decidim-consultations-0.26.7 app/forms/decidim/consultations/admin/question_configuration_form.rb
decidim-consultations-0.26.5 app/forms/decidim/consultations/admin/question_configuration_form.rb
decidim-consultations-0.27.2 app/forms/decidim/consultations/admin/question_configuration_form.rb
decidim-consultations-0.27.1 app/forms/decidim/consultations/admin/question_configuration_form.rb
decidim-consultations-0.26.4 app/forms/decidim/consultations/admin/question_configuration_form.rb
decidim-consultations-0.27.0 app/forms/decidim/consultations/admin/question_configuration_form.rb
decidim-consultations-0.26.3 app/forms/decidim/consultations/admin/question_configuration_form.rb
decidim-consultations-0.27.0.rc2 app/forms/decidim/consultations/admin/question_configuration_form.rb
decidim-consultations-0.27.0.rc1 app/forms/decidim/consultations/admin/question_configuration_form.rb
decidim-consultations-0.26.2 app/forms/decidim/consultations/admin/question_configuration_form.rb