diff --git a/CHANGELOG.md b/CHANGELOG.md index 1577d68..928b5c0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# v7.2.0 +## mm/dd/2023 + +1. [](#bugfix) + * Fixed a long-standing bug with cached forms not working properly in multi-language scenarios + # v7.1.3 ## 05/09/2023 diff --git a/form.php b/form.php index bd96770..9ed14b1 100644 --- a/form.php +++ b/form.php @@ -65,8 +65,6 @@ class FormPlugin extends Plugin protected $active_forms = []; /** @var array */ protected $json_response = []; - /** @var bool */ - protected $recache_forms = false; /** * @return bool @@ -223,11 +221,6 @@ public function onPageInitialized(): void $submitted = false; $this->json_response = []; - // Save cached forms. - if ($this->recache_forms) { - $this->saveCachedForms(); - } - /** @var PageInterface $page */ $page = $this->grav['page']; @@ -838,9 +831,8 @@ public function addFormDefinition(PageInterface $page, string $name, array $form if (!isset($this->forms[$route][$name])) { $form['_page_routable'] = !$page->isModule(); - $this->forms[$route][$name] = $form; - $this->recache_forms = true; + $this->saveCachedForms(); } } @@ -863,7 +855,7 @@ public function addForm(?string $route, ?FormInterface $form): void $form['_page_routable'] = true; $this->forms[$route][$name] = $form; - $this->recache_forms = true; + $this->saveCachedForms(); } } @@ -1267,13 +1259,6 @@ protected function loadCachedForms(): void */ protected function saveCachedForms(): void { - // Save the current state of the forms to cache - if (!$this->recache_forms) { - return; - } - - $this->recache_forms = false; - /** @var Cache $cache */ $cache = $this->grav['cache'];