Sha256: b383dea9d5cc5305a9f1c95f4ddd217e3d59e0e4b48c0dd85e88b0637691157f
Contents?: true
Size: 1.75 KB
Versions: 3
Compression:
Stored size: 1.75 KB
Contents
# frozen_string_literal: true module Decidim module Initiatives module Admin # A form object used to collect the all the initiative type attributes. class InitiativeTypeForm < Decidim::Form include TranslatableAttributes mimic :initiatives_type translatable_attribute :title, String translatable_attribute :description, String attribute :banner_image, String attribute :signature_type, String attribute :undo_online_signatures_enabled, Boolean attribute :promoting_committee_enabled, Boolean attribute :minimum_committee_members, Integer attribute :collect_user_extra_fields, Boolean translatable_attribute :extra_fields_legal_information, String attribute :validate_sms_code_on_votes, Boolean attribute :document_number_authorization_handler, String validates :title, :description, translatable_presence: true validates :undo_online_signatures_enabled, :promoting_committee_enabled, inclusion: { in: [true, false] } validates :minimum_committee_members, numericality: { only_integer: true }, allow_nil: true validates :banner_image, presence: true, if: ->(form) { form.context.initiative_type.nil? } def minimum_committee_members=(value) super(value.presence) end def minimum_committee_members return 0 unless promoting_committee_enabled? super end def signature_type_options Initiative.signature_types.keys.map do |type| [ I18n.t( type, scope: %w(activemodel attributes initiative signature_type_values) ), type ] end end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems