diff --git a/lib/trestle/adapters/active_record_adapter.rb b/lib/trestle/adapters/active_record_adapter.rb index 4d01f301..85493260 100644 --- a/lib/trestle/adapters/active_record_adapter.rb +++ b/lib/trestle/adapters/active_record_adapter.rb @@ -43,13 +43,13 @@ def human_attribute_name(attribute, options={}) def default_table_attributes default_attributes.reject do |attribute| - inheritance_column?(attribute) || counter_cache_column?(attribute) + inheritance_column?(attribute) || counter_cache_column?(attribute) || admin.remove_table_attributes&.include?(attribute.name.to_s) end end def default_form_attributes default_attributes.reject do |attribute| - primary_key?(attribute) || inheritance_column?(attribute) || counter_cache_column?(attribute) + primary_key?(attribute) || inheritance_column?(attribute) || counter_cache_column?(attribute) || admin.remove_form_attributes&.include?(attribute.name.to_s) end end diff --git a/lib/trestle/admin.rb b/lib/trestle/admin.rb index 74ff1cf4..26e8717e 100644 --- a/lib/trestle/admin.rb +++ b/lib/trestle/admin.rb @@ -25,6 +25,9 @@ class << self attr_accessor :menu attr_accessor :form + attr_accessor :remove_form_attributes + attr_accessor :remove_table_attributes + attr_accessor :remove_select_attributes attr_writer :options attr_writer :breadcrumb diff --git a/lib/trestle/form/automatic.rb b/lib/trestle/form/automatic.rb index 6da26c26..bbc27c23 100644 --- a/lib/trestle/form/automatic.rb +++ b/lib/trestle/form/automatic.rb @@ -22,7 +22,11 @@ def initialize(admin, options={}) else prompt = I18n.t("admin.form.select.prompt", default: "- Select %{attribute_name} -", attribute_name: admin.human_attribute_name(attribute.association_name)) - select attribute.name, attribute.association_class.all, include_blank: prompt + if admin.remove_select_attributes.include?(attribute.name.to_s) + text_field attribute.name + else + select attribute.name, attribute.association_class.all, include_blank: prompt + end end when :text text_area attribute.name