Sha256: 221d773ad069b085836bfa812437896d93c643d43cee039e73203c37bf4f783a

Contents?: true

Size: 703 Bytes

Versions: 4

Compression:

Stored size: 703 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module Debates
    # This class holds a Form to create/update debates from Decidim's admin panel.
    class DebateForm < Decidim::Form
      include TranslatableAttributes

      attribute :title, String
      attribute :description, String
      attribute :category_id, Integer
      attribute :user_group_id, Integer

      validates :title, presence: true
      validates :description, presence: true

      validates :category, presence: true, if: ->(form) { form.category_id.present? }

      def category
        return unless current_feature
        @category ||= current_feature.categories.where(id: category_id).first
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
decidim-debates-0.9.3 app/forms/decidim/debates/debate_form.rb
decidim-debates-0.9.2 app/forms/decidim/debates/debate_form.rb
decidim-debates-0.9.1 app/forms/decidim/debates/debate_form.rb
decidim-debates-0.9.0 app/forms/decidim/debates/debate_form.rb