Sha256: ff1b04eeec78d0553d76de0c3cf079917e3980c01047808cc703e10ea516d7d7
Contents?: true
Size: 1.07 KB
Versions: 2
Compression:
Stored size: 1.07 KB
Contents
# frozen_string_literal: true module Decidim module Proposals # A form object to be used when public users want to create a proposal. class ProposalForm < Decidim::Form mimic :proposal attribute :title, String attribute :body, String attribute :category_id, Integer attribute :scope_id, Integer attribute :user_group_id, Integer validates :title, :body, presence: true validates :category, presence: true, if: ->(form) { form.category_id.present? } validates :scope, presence: true, if: ->(form) { form.scope_id.present? } delegate :categories, to: :current_feature delegate :scopes, to: :current_organization alias feature current_feature # Finds the Category from the category_id. # # Returns a Decidim::Category def category @category ||= categories.where(id: category_id).first end # Finds the Scope from the scope_id. # # Returns a Decidim::Scope def scope @scope ||= scopes.where(id: scope_id).first end end end end
Version data entries
2 entries across 2 versions & 2 rubygems
Version | Path |
---|---|
decidim-proposals-0.0.3 | app/forms/decidim/proposals/proposal_form.rb |
decidim-0.0.3 | decidim-proposals/app/forms/decidim/proposals/proposal_form.rb |