def attachment_cache_field(object_name, method, object:, **options)
      options[:data] ||= {}
      options[:data][:reference] ||= SecureRandom.hex

      attacher_value = object.send("#{method}_data")

      hidden_options = {
        multiple: options[:multiple],
        value: attacher_value.try(:to_json),
        object: object,
        disabled: attacher_value.blank?,
        id: nil,
        data: { reference: options[:data][:reference] }
      }
      hidden_options.merge!(index: options[:index]) if options.key?(:index)

      hidden_field(object_name, method, hidden_options)
    end
def attachment_cache_field(object_name, method, object:, **options)
      options[:data] ||= {}
      options[:data][:reference] ||= SecureRandom.hex

      attacher_value = object.send("#{method}_data")

      hidden_options = {
        multiple: options[:multiple],
        value: attacher_value.try(:to_json),
        object: object,
        disabled: attacher_value.blank?,
        id: nil,
        data: { reference: options[:data][:reference] }
      }
      hidden_options.merge!(index: options[:index]) if options.key?(:index)

      hidden_field(object_name, method, hidden_options)
    end
Generates a hidden form field which tracks the id of the file in the cache
 before it is permanently stored.

 @param object_name                    The name of the object to generate a field for
 @param method                         The name of the field
 @param [Hash] options
 @option options [Object] object       Set by the form builder
 @return [ActiveSupport::SafeBuffer]   The generated hidden form field