Skip to content

Commit

Permalink
Merge 6cd6fd1 into 06970b9
Browse files Browse the repository at this point in the history
  • Loading branch information
zealot128 committed Sep 12, 2021
2 parents 06970b9 + 6cd6fd1 commit dfcc508
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/trestle/form/automatic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,15 @@ def initialize(admin, options={})
datetime_field attribute.name
when :boolean
check_box attribute.name
when :integer
if instance.class.respond_to?(attribute.name.to_s.pluralize)
# AR Enum
values = instance.class.send(attribute.name.to_s.pluralize).keys.map { |status| [status, status.humanize] }

collection_radio_buttons(attribute.name, values, :first, :last)
else
text_field attribute.name
end
when :json, :jsonb
value = instance.public_send(attribute.name)
text_area attribute.name, value: value.try(:to_json)
Expand Down

0 comments on commit dfcc508

Please sign in to comment.