简体   繁体   中英

Drupal 8/9 module no refresh form data after post

I have a D8 module that works well. But I have a problem. Sensors data are stored in a database. In the D8 website, the cache is disabled, but the selected data are not updated. If I use the "drush cr" then ok, but the next selected data are not updated. What may be the problem? The code shortly:

#
# form for SQL SELECT
#
function buildForm()
//...
$form['date_from'] = [ '#type' => 'datetime', ... ];
$form['date_to'] = ...
$form['#cache'] = ['max-age' => 0];
/// ...

So, I select a date_from and date_to and post it then it is ok. I go back and change the date_from, date_to and post it then it still stay the previous date. After "drush cr" it works once again... and so on

It has no effect (settings.php): $settings['rebuild_access'] = TRUE;

Thanks, G.

I found it: How to clear cache programmatically in Drupal 8?

Both work. :)

in function buildForm():

drupal_flush_all_caches();
// or
\Drupal::service("router.builder")->rebuild();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM