lib/avo/fields/belongs_to_field.rb in avo-1.20.2.pre.2 vs lib/avo/fields/belongs_to_field.rb in avo-1.21.0.pre.1
- old
+ new
@@ -1,11 +1,12 @@
module Avo
module Fields
class BelongsToField < BaseField
+ attr_reader :searchable
attr_reader :polymorphic_as
attr_reader :relation_method
- attr_reader :types # for Polymorphic associations
+ attr_reader :types
def initialize(id, **args, &block)
args[:placeholder] ||= I18n.t("avo.choose_an_option")
super(id, **args, &block)
@@ -14,29 +15,11 @@
@polymorphic_as = args[:polymorphic_as]
@types = args[:types]
@relation_method = name.to_s.parameterize.underscore
end
- def searchable
- @searchable && ::Avo::App.license.has_with_trial(:searchable_belongs_to)
- end
-
def value
super(polymorphic_as)
- end
-
- # The value
- def field_value
- value.send(database_value)
- rescue
- nil
- end
-
- # What the user sees in the text field
- def field_label
- value.send(target_resource.class.title)
- rescue
- nil
end
def options
::Avo::Services::AuthorizationService.apply_policy(user, target_resource.class.query_scope).all.map do |model|
{