Sha256: a9a08adbb992a1c538ed1cc7c852a303f2bc98c300ecdb077b8caba862f3a5b0

Contents?: true

Size: 466 Bytes

Versions: 10

Compression:

Stored size: 466 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module Plans
    class AttachmentForm < Decidim::Form
      attribute :title, String
      attribute :file
      attribute :weight, Integer
      attribute :deleted, Boolean, default: false

      mimic :attachment

      validates :title, presence: true, if: ->(form) { form.file.present? || form.id.present? }

      def to_param
        return id if id.present?

        "attachment-id"
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
decidim-plans-0.18.2 app/forms/decidim/plans/attachment_form.rb
decidim-plans-0.18.1 app/forms/decidim/plans/attachment_form.rb
decidim-plans-0.18.0 app/forms/decidim/plans/attachment_form.rb
decidim-plans-0.17.0 app/forms/decidim/plans/attachment_form.rb
decidim-plans-0.16.9 app/forms/decidim/plans/attachment_form.rb
decidim-plans-0.16.8 app/forms/decidim/plans/attachment_form.rb
decidim-plans-0.16.7 app/forms/decidim/plans/attachment_form.rb
decidim-plans-0.16.6 app/forms/decidim/plans/attachment_form.rb
decidim-plans-0.16.5 app/forms/decidim/plans/attachment_form.rb
decidim-plans-0.16.4 app/forms/decidim/plans/attachment_form.rb