Skip to content

Commit

Permalink
Merge branch 'release/5.0.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
rhukster committed Apr 23, 2021
2 parents 3afabcf + f2ddd67 commit 16de542
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 4 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# v5.0.2
## 04/23/2021

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

Expand Down
2 changes: 1 addition & 1 deletion blueprints.yaml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
13 changes: 12 additions & 1 deletion classes/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion languages.yaml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
2 changes: 1 addition & 1 deletion templates/forms/fields/toggle/toggle.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}

<input type="radio"
Expand Down

0 comments on commit 16de542

Please sign in to comment.