Sha256: edb2df5000b6c0f13723742a2e545711c604c459e5e500ceeeb0d4a806f7b5f8
Contents?: true
Size: 898 Bytes
Versions: 90
Compression:
Stored size: 898 Bytes
Contents
module Avo module Fields class CountryField < BaseField include Avo::Fields::FieldExtensions::HasIncludeBlank attr_reader :countries attr_reader :display_code def initialize(id, **args, &block) args[:placeholder] ||= I18n.t("avo.choose_a_country") super(id, **args, &block) @countries = begin ISO3166::Country.translations.sort_by { |code, name| name }.to_h rescue {none: "You need to install the countries gem for this field to work properly"} end @display_code = args[:display_code].present? ? args[:display_code] : false end def select_options if @display_code countries.map do |code, name| [code, code] end else countries.map do |code, name| [name, code] end end end end end end
Version data entries
90 entries across 90 versions & 1 rubygems