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.26.1 app/forms/decidim/consultations/admin/question_configuration_form.rb
decidim-consultations-0.26.0 app/forms/decidim/consultations/admin/question_configuration_form.rb
decidim-consultations-0.26.0.rc2 app/forms/decidim/consultations/admin/question_configuration_form.rb
decidim-consultations-0.26.0.rc1 app/forms/decidim/consultations/admin/question_configuration_form.rb
decidim-consultations-0.25.2 app/forms/decidim/consultations/admin/question_configuration_form.rb
decidim-consultations-0.25.1 app/forms/decidim/consultations/admin/question_configuration_form.rb
decidim-consultations-0.25.0 app/forms/decidim/consultations/admin/question_configuration_form.rb
decidim-consultations-0.25.0.rc4 app/forms/decidim/consultations/admin/question_configuration_form.rb
decidim-consultations-0.25.0.rc3 app/forms/decidim/consultations/admin/question_configuration_form.rb
decidim-consultations-0.25.0.rc2 app/forms/decidim/consultations/admin/question_configuration_form.rb
decidim-consultations-0.25.0.rc1 app/forms/decidim/consultations/admin/question_configuration_form.rb
decidim-consultations-0.24.3 app/forms/decidim/consultations/admin/question_configuration_form.rb
decidim-consultations-0.23.6 app/forms/decidim/consultations/admin/question_configuration_form.rb
decidim-consultations-0.24.2 app/forms/decidim/consultations/admin/question_configuration_form.rb
decidim-consultations-0.23.5 app/forms/decidim/consultations/admin/question_configuration_form.rb
decidim-consultations-0.24.1 app/forms/decidim/consultations/admin/question_configuration_form.rb
decidim-consultations-0.24.0 app/forms/decidim/consultations/admin/question_configuration_form.rb
decidim-consultations-0.24.0.rc2 app/forms/decidim/consultations/admin/question_configuration_form.rb
decidim-consultations-0.23.4 app/forms/decidim/consultations/admin/question_configuration_form.rb
decidim-consultations-0.24.0.rc1 app/forms/decidim/consultations/admin/question_configuration_form.rb