Skip to content

Commit

Permalink
Merge branch 'release/2.0.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
rhukster committed Sep 12, 2016
2 parents 31dd2d0 + a216185 commit c441251
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# v2.0.3
## 09/12/2016

1. [](#improved)
* Use `Page::slug()` for form name if not set in the form itself (better backwards compatibility)

# v2.0.2
## 09/08/2016

Expand Down
2 changes: 1 addition & 1 deletion blueprints.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Form
version: 2.0.2
version: 2.0.3
description: Enables the forms handling
icon: check-square
author:
Expand Down
2 changes: 2 additions & 0 deletions classes/form.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ class Form extends Iterator implements \Serializable
* Create form for the given page.
*
* @param Page $page
* @param null $name
* @param null $form
*/
public function __construct(Page $page, $name = null, $form = null)
{
Expand Down
17 changes: 16 additions & 1 deletion form.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ public function onPagesInitialized()
'onFormValidationError' => ['onFormValidationError', 0]
]);

$current_form_name = filter_input(INPUT_POST, '__form-name__');
$current_form_name = $this->getFormName($this->grav['page']);
$this->json_response = [];

if ($form = $this->getFormByName($current_form_name)) {
Expand Down Expand Up @@ -536,6 +536,21 @@ private function udate($format = 'u', $utimestamp = null)
return date(preg_replace('`(?<!\\\\)u`', \sprintf('%06d', $milliseconds), $format), $timestamp);
}

/**
* @param Page $page
* @return mixed
*/
private function getFormName(Page $page)
{
$name = filter_input(INPUT_POST, '__form-name__');

if (!$name) {
$name = $page->slug();
}

return $name;
}

/**
* function to get a specific form
*
Expand Down

0 comments on commit c441251

Please sign in to comment.