Sha256: 93ffc3aa616e695fc573a6616d9b34969b6fb3aabc760ae274fd9a8f544e1cb4
Contents?: true
Size: 878 Bytes
Versions: 7
Compression:
Stored size: 878 Bytes
Contents
# frozen_string_literal: true module Decidim module Votings module Admin class VotingUserRoleForm < Decidim::Form attribute :name, String attribute :email, String attribute :user_id, Integer attribute :existing_user, Boolean, default: false validates :email, presence: true, format: { with: ::Devise.email_regexp }, unless: ->(form) { form.existing_user } validates :name, presence: true, format: { with: UserBaseEntity::REGEXP_NAME }, unless: ->(form) { form.existing_user } validates :user, presence: true, if: ->(form) { form.existing_user } def map_model(model) self.user_id = model.decidim_user_id self.existing_user = user_id.present? end def user @user ||= current_organization.users.find_by(id: user_id) end end end end end
Version data entries
7 entries across 7 versions & 1 rubygems