Sha256: d09568a6b6a873237dbeb42d3909f35d441943983993a764d0c52ad7563ec574
Contents?: true
Size: 956 Bytes
Versions: 14
Compression:
Stored size: 956 Bytes
Contents
# frozen_string_literal: true module Decidim module Proposals # A form object to be used when public users want to create a proposal. class ProposalWizardCreateStepForm < Decidim::Form mimic :proposal attribute :title, String attribute :body, String attribute :user_group_id, Integer validates :title, :body, presence: true, etiquette: true validates :title, length: { maximum: 150 } validate :proposal_length alias component current_component def map_model(model) self.user_group_id = model.user_groups.first&.id return unless model.categorization self.category_id = model.categorization.decidim_category_id end private def proposal_length return unless body.presence length = current_component.settings.proposal_length errors.add(:body, :too_long, count: length) if body.length > length end end end end
Version data entries
14 entries across 14 versions & 1 rubygems