Sha256: e3e49c5fb8235af8dff0b91055df411beaa0766188674272bd8eaede7ad13ee7

Contents?: true

Size: 666 Bytes

Versions: 2

Compression:

Stored size: 666 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module Debates
    # This class holds a Form to create/update debates from Decidim's public views.
    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
        @category ||= current_feature.categories.where(id: category_id).first
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
decidim-debates-0.10.1 app/forms/decidim/debates/debate_form.rb
decidim-debates-0.10.0 app/forms/decidim/debates/debate_form.rb