Skip to content

Commit

Permalink
Merge branch 'release/2.3.0'
Browse files Browse the repository at this point in the history
# Conflicts:
#	CHANGELOG.md
  • Loading branch information
rhukster committed Mar 17, 2017
2 parents 839548c + e2d8f75 commit 6b34502
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 12 deletions.
11 changes: 7 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# v2.2.1
## 03/xx/2017
# v2.3.0
## 03/17/2017

![](#bugfix)
1. [](#new)
* Ability to process any form on any page via `action:`. Super useful if you want to handle form processing on some other non-form page (or Ajax)
* Added the ability for the form to set the `template:` to use to render the form processing response.
1. [](#bugfix)
* Fix `number` field so it works with min value `0` [#130](https://github.com/getgrav/grav-plugin-form/issues/130)

# v2.2.0
Expand All @@ -11,7 +14,7 @@
* Added new `fieldset` form field [#125](https://github.com/getgrav/grav-plugin-form/issues/125)
* Added new `conditional form field` to show fields only if some `condition` is set
1. [](#improved)
* Added the option to have outerclasses on buttons [#124](https://github.com/getgrav/grav-plugin-form/issues/124)
* Added the option to have outer-classes on buttons [#124](https://github.com/getgrav/grav-plugin-form/issues/124)
* Added the option to disable fields label if not defined [#126](https://github.com/getgrav/grav-plugin-form/issues/126)

# v2.1.1
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.2.0
version: 2.3.0
description: Enables the forms handling
icon: check-square
author:
Expand Down
19 changes: 13 additions & 6 deletions form.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,16 +189,16 @@ public function onPagesInitialized()
$current_form_name = $this->getFormName($this->grav['page']);
$this->json_response = [];

if ($form = $this->getFormByName($current_form_name)) {
if ($this->form = $this->getFormByName($current_form_name)) {
if ($this->grav['uri']->extension() === 'json' && isset($_POST['__form-file-uploader__'])) {
$this->json_response = $form->uploadFiles();
$this->json_response = $this->form->uploadFiles();
} else {
$form->post();
$this->form->post();
$submitted = true;
}
} elseif (isset($this->grav['page']->header()->form)) {
$form = new Form($this->grav['page']);
$form->post();
$this->form = new Form($this->grav['page']);
$this->form->post();
$submitted = true;
}
}
Expand Down Expand Up @@ -259,7 +259,9 @@ public function onTwigVariables(Event $event = null)
$current_page_route = $this->getCurrentPageRoute();
$found_forms = [];

if (!isset($this->grav['twig']->twig_vars['form'])) {
if (isset($this->form)) {
$this->grav['twig']->twig_vars['form'] = $this->form;
} elseif (!isset($this->grav['twig']->twig_vars['form'])) {
if (isset($this->forms[$page_route])) {
$found_forms = $this->forms[$page_route];
} elseif (isset($this->forms[$current_page_route])) {
Expand Down Expand Up @@ -527,6 +529,11 @@ protected function process($form)
}
}
}

// Set page template if passed by form
if (isset($form->template)) {
$this->grav['page']->template($form->template);
}
}

/**
Expand Down
7 changes: 7 additions & 0 deletions templates/form-messages.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{% if form.message %}
{% if form.inline_errors and form.messages %}
<div class="alert notices {{ form.message_color ?: 'green' }}"><p>{{ "FORM.VALIDATION_FAIL"|t|raw }}</p></div>
{% else %}
<div class="alert notices {{ form.message_color ?: 'green' }}"><p>{{ form.message|raw }}</p></div>
{% endif %}
{% endif %}
2 changes: 1 addition & 1 deletion templates/forms/fields/captcha/captcha.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<script>
var captchaOnloadCallback = function captchaOnloadCallback() {
grecaptcha.render('g-recaptcha', {
'sitekey': "{{field.recaptcha_site_key ?: field.recatpcha_site_key ?: config.plugins.form.recaptcha.site_key }}",
'sitekey': "{{field.recaptcha_site_key ?: field.recaptcha_site_key ?: config.plugins.form.recaptcha.site_key }}",
'callback': captchaValidatedCallback,
'expired-callback': captchaExpiredCallback
});
Expand Down

0 comments on commit 6b34502

Please sign in to comment.