class Avo::Fields::BelongsToField::EditComponent

def disabled

def disabled
  return true if @field.is_readonly? || @field.is_disabled?
  # When visiting the record through it's association we keep the field disabled by default
  # We make an exception when the user deliberately instructs Avo to allow detaching in this scenario
  return !@field.allow_via_detaching if @field.target_resource.present? && visit_through_association?
  return !@field.allow_via_detaching if @field.id.to_s == params[:via_relation].to_s
  false
end