Sha256: 044f7a561768259898adf8720a167780ddcec0fb440695e3de40ad634756ae32

Contents?: true

Size: 991 Bytes

Versions: 6

Compression:

Stored size: 991 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module Plans
    module Admin
      # A form object to be used when admin users want to create a plan.
      class SectionForm < Decidim::Form
        include TranslatableAttributes
        include Decidim::ApplicationHelper

        mimic :section

        translatable_attribute :body, String
        translatable_attribute :help, String
        attribute :mandatory, Boolean, default: false
        attribute :answer_length, Integer, default: 0
        attribute :section_type, String
        attribute :position, Integer
        attribute :deleted, Boolean, default: false

        validates :position, numericality: { greater_than_or_equal_to: 0 }
        validates :body, translatable_presence: true, unless: :deleted
        validates :answer_length, numericality: {
          greater_than_or_equal_to: 0,
          only_integer: true
        }

        def to_param
          id || "section-id"
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
decidim-plans-0.16.3 app/forms/decidim/plans/admin/section_form.rb
decidim-plans-0.16.2 app/forms/decidim/plans/admin/section_form.rb
decidim-plans-0.16.1 app/forms/decidim/plans/admin/section_form.rb
decidim-plans-0.16.0 app/forms/decidim/plans/admin/section_form.rb
decidim-plans-0.15.1 app/forms/decidim/plans/admin/section_form.rb
decidim-plans-0.15.0 app/forms/decidim/plans/admin/section_form.rb