From c270487e3827cf04cc415151e4f18a30585d98c0 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Thu, 18 Mar 2021 11:57:02 -0600 Subject: [PATCH 1/4] Better message for invalid nonce - fixes #513 --- CHANGELOG.md | 6 ++++++ languages.yaml | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2141aed..22bee9a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# v5.0.2 +## mm/dd/2021 + +1. [](#improved) + * Better message for invalid nonce [#513](https://github.com/getgrav/grav-plugin-form/issues/513) + # v5.0.1 ## 03/17/2021 diff --git a/languages.yaml b/languages.yaml index a6bd8bd..4b2f06d 100644 --- a/languages.yaml +++ b/languages.yaml @@ -1,7 +1,7 @@ en: PLUGIN_FORM: NOT_VALIDATED: "Form not validated. One or more required fields are missing." - NONCE_NOT_VALIDATED: "Oops there was a problem, please check your input and submit the form again." + NONCE_NOT_VALIDATED: "Oops, your form has timed out, please reload the page and submit the form again." FILES: "Files Upload" FORM_ALREADY_SUBMITTED: "This form has already been submitted." ALLOW_MULTIPLE: "Allow More than one file" From e70f34d89c8ad52a3b9783e62446a115879c36b2 Mon Sep 17 00:00:00 2001 From: Matias Griese Date: Tue, 13 Apr 2021 09:54:51 +0300 Subject: [PATCH 2/4] Better error if `Form::getPage()` gets called too early [#518] --- CHANGELOG.md | 1 + classes/Form.php | 13 ++++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 22bee9a..e4158a2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ 1. [](#improved) * Better message for invalid nonce [#513](https://github.com/getgrav/grav-plugin-form/issues/513) + * Better error if `Form::getPage()` gets called too early [#518](https://github.com/getgrav/grav-plugin-form/issues/518) # v5.0.1 ## 03/17/2021 diff --git a/classes/Form.php b/classes/Form.php index 71c1a3b..6bfcdd6 100644 --- a/classes/Form.php +++ b/classes/Form.php @@ -12,6 +12,7 @@ use Grav\Common\Inflector; use Grav\Common\Language\Language; use Grav\Common\Page\Interfaces\PageInterface; +use Grav\Common\Page\Pages; use Grav\Common\Security; use Grav\Common\Uri; use Grav\Common\Utils; @@ -390,11 +391,21 @@ public function getFields(): array /** * Return page object for the form. * + * Can be called only after onPageInitialize event has fired. + * * @return PageInterface + * @throws \LogicException */ public function getPage(): PageInterface { - return Grav::instance()['pages']->dispatch($this->page); + /** @var Pages $pages */ + $pages = Grav::instance()['pages']; + $page = $pages->find($this->page); + if (null === $page) { + throw new \LogicException('Form::getPage() method was called too early!'); + } + + return $page; } /** From 4a9a56063be6d7b02ad2989c9cff2730cbfa92c6 Mon Sep 17 00:00:00 2001 From: Matias Griese Date: Fri, 23 Apr 2021 21:21:34 +0300 Subject: [PATCH 3/4] Added support for custom Toggle id --- CHANGELOG.md | 3 ++- templates/forms/fields/toggle/toggle.html.twig | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e4158a2..6322545 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,8 @@ 1. [](#improved) * Better message for invalid nonce [#513](https://github.com/getgrav/grav-plugin-form/issues/513) * Better error if `Form::getPage()` gets called too early [#518](https://github.com/getgrav/grav-plugin-form/issues/518) - + * Added support for custom Toggle id + # v5.0.1 ## 03/17/2021 diff --git a/templates/forms/fields/toggle/toggle.html.twig b/templates/forms/fields/toggle/toggle.html.twig index e1353e9..1c51b2e 100644 --- a/templates/forms/fields/toggle/toggle.html.twig +++ b/templates/forms/fields/toggle/toggle.html.twig @@ -33,7 +33,7 @@ {% for key, text in field.options %} {% set key = key|string %} - {% set id = "toggle_" ~ field.name ~ key %} + {% set id = (field.id ?? ("toggle_" ~ field.name)) ~ key %} {% set translation = text|t|trim %} Date: Fri, 23 Apr 2021 12:50:20 -0600 Subject: [PATCH 4/4] prepare for release --- CHANGELOG.md | 2 +- blueprints.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6322545..d4ad9a4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,5 @@ # v5.0.2 -## mm/dd/2021 +## 04/23/2021 1. [](#improved) * Better message for invalid nonce [#513](https://github.com/getgrav/grav-plugin-form/issues/513) diff --git a/blueprints.yaml b/blueprints.yaml index 66b8ab0..be5b4ad 100644 --- a/blueprints.yaml +++ b/blueprints.yaml @@ -1,7 +1,7 @@ name: Form slug: form type: plugin -version: 5.0.1 +version: 5.0.2 description: Enables the forms handling icon: check-square author: