From 34793163d9bae001178ff0ebb1ae37340eb71b6c Mon Sep 17 00:00:00 2001 From: Chris Oliver Date: Thu, 29 Aug 2024 09:11:05 -0500 Subject: [PATCH] Handle create & update actions for visibility --- lib/madmin/field.rb | 2 +- lib/madmin/resource.rb | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/madmin/field.rb b/lib/madmin/field.rb index f0d7ba7..37b5f62 100644 --- a/lib/madmin/field.rb +++ b/lib/madmin/field.rb @@ -36,7 +36,7 @@ def visible?(action) case action when :index default_index_attributes.include?(attribute_name) - when :new, :edit + when :new, :create, :edit, :update # Hidden attributes for forms [:id, :created_at, :updated_at].exclude?(attribute_name) else diff --git a/lib/madmin/resource.rb b/lib/madmin/resource.rb index dafd8f8..8b20653 100644 --- a/lib/madmin/resource.rb +++ b/lib/madmin/resource.rb @@ -50,7 +50,9 @@ def attribute(name, type = nil, **options) if config.has_key?(:form) value = config.delete(:form) config.new = value + config.create = value config.edit = value + config.update = value end attributes[name] = OpenStruct.new(