app/forms/decidim/proposals/admin/proposal_base_form.rb in decidim-proposals-0.23.6 vs app/forms/decidim/proposals/admin/proposal_base_form.rb in decidim-proposals-0.24.0.rc1
- old
+ new
@@ -4,10 +4,11 @@
module Proposals
module Admin
# A form object to be used when admin users want to create a proposal.
class ProposalBaseForm < Decidim::Form
include Decidim::TranslatableAttributes
+ include Decidim::AttachmentAttributes
include Decidim::ApplicationHelper
mimic :proposal
attribute :address, String
@@ -18,11 +19,11 @@
attribute :attachment, AttachmentForm
attribute :position, Integer
attribute :created_in_meeting, Boolean
attribute :meeting_id, Integer
attribute :suggested_hashtags, Array[String]
- attribute :photos, Array[String]
- attribute :add_photos, Array
+
+ attachments_attribute :photos
validates :address, geocoding: true, if: ->(form) { form.has_address? && !form.geocoded? }
validates :category, presence: true, if: ->(form) { form.category_id.present? }
validates :scope, presence: true, if: ->(form) { form.scope_id.present? }
validates :scope_id, scope_belongs_to_component: true, if: ->(form) { form.scope_id.present? }