Skip to content

Commit

Permalink
fix double radio issue by setting the field_name_attribute on the plu…
Browse files Browse the repository at this point in the history
…ggy field
  • Loading branch information
Paul-Bob committed Nov 18, 2024
1 parent 6fe4b05 commit 4e34a5a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 4 additions & 6 deletions lib/avo/fields/field_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,11 @@ def all
# Avo::Fields::DateTimeField -> date_time
def init_fields
Avo::Fields::BaseField.descendants.each do |class_name|
next unless valid_class_name?(class_name)
next if class_name.to_s == "BaseField"

load_field class_name.get_field_name, class_name
if class_name.to_s.end_with? "Field"
load_field class_name.get_field_name, class_name
end
end
end

Expand All @@ -56,10 +58,6 @@ def load_field(name, klass)
def field_exists?(name)
fields.pluck(:name).map(&:to_sym).include?(name.to_sym)
end

def valid_class_name?(class_name)
class_name.to_s != "BaseField" && class_name.to_s.starts_with?("Avo::Fields") && class_name.to_s.end_with?("Field")
end
end
end
end
2 changes: 2 additions & 0 deletions pluggy/lib/pluggy/fields/radio_field.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ class RadioField < Avo::Fields::BaseField

attr_reader :options

self.field_name_attribute = :pluggy_radio

def initialize(id, **args, &block)
super(id, **args, &block)

Expand Down

0 comments on commit 4e34a5a

Please sign in to comment.