# Disable autofill in dashboard

**URL:** <https://discourse.openondemand.org/t/disable-autofill-in-dashboard/456>\
**Category:** Get Help\
**Created:** [August 3, 2019, 11:12am UTC](https://discourse.openondemand.org/t/disable-autofill-in-dashboard/456 "2019-08-03T11:12:04Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jms27000](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/jms27000/32/147_2.png) [@jms27000](https://discourse.openondemand.org/u/jms27000)\
**Post date:** [August 3, 2019, 11:12am UTC](https://discourse.openondemand.org/t/disable-autofill-in-dashboard/456/1 "2019-08-03T11:12:04Z")

</div>

Hi,

In the doc, it’s indicated that dashboard remains previous values in form. This is a problem if you want to initialize dynamicaly some value with erb scripts inside the «initializers» of the dashboard.  
Question : is there any way to disable the autofill mechanism into the dashboard ?

Thanks

Jean-Marie

---

<div class="post-metadata">

**Author:** ![rodgers.355](https://sea1.discourse-cdn.com/flex015/user_avatar/discourse.openondemand.org/rodgers.355/32/193_2.png) [@rodgers.355](https://discourse.openondemand.org/u/rodgers.355)\
**Post date:** [August 22, 2019, 3:26pm UTC](https://discourse.openondemand.org/t/disable-autofill-in-dashboard/456/2 "2019-08-22T15:26:33Z")

</div>

@jms27000 I hope your vacations are going well. Another response for you:

I think that you are asking about the Batch Connect forms? The auto fill mechanism is built around a file named `context.json`. By preventing the creation and reading of that file we can prevent the auto fill from occurring.

We can patch this feature in by adding a custom initializer to the Dashboard’s configuration by adding a file like: `/etc/ood/config/apps/dashboard/initializers/bc_app_context_cache_buster.rb`.

An example implementation follows:

```ruby
# /etc/ood/config/apps/dashboard/initializers/bc_app_context_cache_buster.rb
require 'batch_connect/session_contexts_controller'

class BatchConnect::SessionContextsController
  # Implements a portion of the Pathname interface
  # 
  # ...that BatchConnect::SessionContextsController uses for interacting with context.json
  class CacheDenier
    # Prevent loading pre-existing context.json
    def file?
      false
    end

    # Prevent creating new context.json
    def write(*args, **kwargs)
      # Do nothing
    end
  end

  ##
  # Override default cache file handler
  # 
  # Add logic to the unless block to control whether the 
  def cache_file
    unless should_skip_cache
      # Perform the normal action
      BatchConnect::Session.dataroot(@app.token).tap { |p| p.mkpath unless p.exist? }.join("context.json")
    else
      # Do not use the context cache file
      CacheDenier.new
    end
  end

  ##
  # Custom logic to determine if caching the context should be skipped
  # 
  # Works by comparing a Set of identifiers of apps that should not have their
  # context saved to a Set of attributes that provide those identifiers
  # 
  # - Note that this is only an example; add your own list of apps to skip saving the context for here or any other test that makes sense
  # - Note that @app is an instance of [BatchConnect::App](https://github.com/OSC/ood-dashboard/blob/master/app/models/batch_connect/app.rb)
  def should_skip_cache
    # A list of app names or sub_apps we want to skip saving the context for
    Set.new([
      'app_that_should_not_have_its_context_cached',
      'another_special_app',
      # Examples for copy/paste testing at OSC
      'bc_osc_jupyter', # an app
      'vdi-owens' # a sub_app
    ]).intersect? Set.new([
      @app.router.name, # matches the app directory
      @app.sub_app
    ])
  end
end

```

---

<div class="post-metadata">

**Author:** ![westburg.2](https://avatars.discourse-cdn.com/v4/letter/w/0ea827/32.png) [@westburg.2](https://discourse.openondemand.org/u/westburg.2)\
**Post date:** [May 26, 2022, 3:21pm UTC](https://discourse.openondemand.org/t/disable-autofill-in-dashboard/456/3 "2022-05-26T15:21:24Z")

</div>


