Sha256: 8d5e961147037e57b1e2ee30d43eef32f51c068a977408ff9661d4335b38cabb

Contents?: true

Size: 719 Bytes

Versions: 94

Compression:

Stored size: 719 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module Admin
    # A form object used to officialize users from the admin dashboard.
    class OfficializationForm < Form
      include TranslatableAttributes

      translatable_attribute :officialized_as, String

      attribute :user_id, Integer

      validates :officialized_as, length: { maximum: 300 }

      validates :user, presence: true, if: ->(form) { form.user_id.present? }

      def map_model(user)
        self.officialized_as = user.officialized_as
        self.user_id = user.id
      end

      def user
        @user ||= Decidim::User.find_by(
          id: user_id,
          organization: current_organization
        )
      end
    end
  end
end

Version data entries

94 entries across 94 versions & 1 rubygems

Version Path
decidim-admin-0.20.1 app/forms/decidim/admin/officialization_form.rb
decidim-admin-0.20.0 app/forms/decidim/admin/officialization_form.rb
decidim-admin-0.19.1 app/forms/decidim/admin/officialization_form.rb
decidim-admin-0.18.1 app/forms/decidim/admin/officialization_form.rb
decidim-admin-0.19.0 app/forms/decidim/admin/officialization_form.rb
decidim-admin-0.17.2 app/forms/decidim/admin/officialization_form.rb
decidim-admin-0.18.0 app/forms/decidim/admin/officialization_form.rb
decidim-admin-0.17.1 app/forms/decidim/admin/officialization_form.rb
decidim-admin-0.16.1 app/forms/decidim/admin/officialization_form.rb
decidim-admin-0.17.0 app/forms/decidim/admin/officialization_form.rb
decidim-admin-0.16.0 app/forms/decidim/admin/officialization_form.rb
decidim-admin-0.15.2 app/forms/decidim/admin/officialization_form.rb
decidim-admin-0.15.1 app/forms/decidim/admin/officialization_form.rb
decidim-admin-0.15.0 app/forms/decidim/admin/officialization_form.rb
decidim-admin-0.14.4 app/forms/decidim/admin/officialization_form.rb
decidim-admin-0.14.3 app/forms/decidim/admin/officialization_form.rb
decidim-admin-0.14.2 app/forms/decidim/admin/officialization_form.rb
decidim-admin-0.14.1 app/forms/decidim/admin/officialization_form.rb
decidim-admin-0.13.1 app/forms/decidim/admin/officialization_form.rb
decidim-admin-0.12.2 app/forms/decidim/admin/officialization_form.rb