Update. 4k4 comment below put me in the right place. According to this post https://drupal.stackexchange.com/a/266393/58880. I needed to apply addCacheableDependency
\Drupal::service('renderer')->addCacheableDependency($variables, $config);
Since I am using hook_node_view. I changed $variables to $build
\Drupal::service('renderer')->addCacheableDependency($build, $config);
Now when I click the checkbox the value of chechbox is correct and its not coming form the config. The text banner is displayed on all nodes. My change is below.
function my_form_configy_node_view(array &$build, \Drupal\Core\Entity\EntityInterface $entity, \Drupal\Core\Entity\Display\EntityViewDisplayInterface $display, $view_mode) {
$config = \Drupal::config('my_form_configy.settings')->get('checkbox');
// add the cache tag, so that the output gets invalidated when the config is saved
\Drupal::service('renderer')->addCacheableDependency($build, $config);
I am trying to understand what this does? Where is the value of 'checkbox' being stored now. Its not in my modules settings.yml file because I have not exported the configuration yet. Is it stored in browser cache, or Drupal cache? Since I am developing I disabled all twig and drupal cache in settings.local.php with.
$settings['cache']['bins']['render'] = 'cache.backend.null';
$settings['cache']['bins']['dynamic_page_cache'] = 'cache.backend.null';
The Devel module is not using addCacheableDependency
Clicking the checkbox 'Display $page array' The dpm feature works immediately.
function devel_page_attachments_alter(&$page) {
if (\Drupal::currentUser()->hasPermission('access devel information') && \Drupal::config('devel.settings')->get('page_alter')) {
dpm($page, 'page');
}
}