Skip to content

Commit

Permalink
Merge branch 'release/2.9.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
rhukster committed Oct 11, 2017
2 parents f6bd799 + bd30888 commit acb8f77
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 11 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
# v2.9.3
## 10/11/2017

1. [](#improved)
* Removed `filesize` plugin configuration in favor of `system.media.upload_limit`
* Consolidated `field.classes` and `field.wrapper_classes` in radio/checkbox/checkboxes [#193](https://github.com/getgrav/grav-plugin-form/issues/)
* Remove trailing slash from form action [#195](https://github.com/getgrav/grav-plugin-form/issues/195)
* Improved `honeypot` validation check [#198](https://github.com/getgrav/grav-plugin-form/issues/198)

# v2.9.2
## 09/30/2017

Expand Down
4 changes: 2 additions & 2 deletions blueprints.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Form
version: 2.9.2
version: 2.9.3
description: Enables the forms handling
icon: check-square
author:
Expand All @@ -12,7 +12,7 @@ bugs: https://github.com/getgrav/grav-plugin-form/issues
license: MIT

dependencies:
- { name: grav, version: '>=1.3.0-rc.3' }
- { name: grav, version: '>=1.3.5' }

form:
validation: strict
Expand Down
2 changes: 1 addition & 1 deletion classes/form.php
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ public function uploadFiles()
'random_name' => $config->get('plugins.form.files.random_name', false),
'accept' => $config->get('plugins.form.files.accept', ['image/*']),
'limit' => $config->get('plugins.form.files.limit', 10),
'filesize' => $config->get('plugins.form.files.filesize', 5242880) // 5MB
'filesize' => $config->get('system.media.upload_limit', 0) // unlimited
],
(array) $settings,
['name' => $post['name']]
Expand Down
6 changes: 4 additions & 2 deletions form.php
Original file line number Diff line number Diff line change
Expand Up @@ -452,8 +452,10 @@ public function onFormProcessed(Event $event)
public function onFormValidationProcessed(Event $event)
{
// special check for honeypot field
if (!empty($event['form']->value('honeypot'))) {
throw new ValidationException('Are you a bot?');
foreach ($event['form']->fields() as $field) {
if ($field['type'] == 'honeypot' && !empty($event['form']->value($field['name']))) {
throw new ValidationException('Are you a bot?');
}
}
}

Expand Down
1 change: 0 additions & 1 deletion form.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ refresh_prevention: false
files:
multiple: false # To allow multiple files, default is single
limit: 10 # Number of allowed files per field (multiple required)
filesize: 5 # Maximum file size allowed (in MB)
destination: 'self@' # Where to upload the files (path and self@, page@, theme@)
avoid_overwriting: false # Prevent files with the same name to be overridden. Date prefix will be added
random_name: false # Generate a random 15 long string name for the uploaded files
Expand Down
2 changes: 1 addition & 1 deletion templates/forms/default/form.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
{% endif %}

<form name="{{ form.name }}"
action="{{ action }}"
action="{{ action | trim('/', 'right') }}"
method="{{ method }}"{{ multipart }}
{% if form.id %}id="{{ form.id }}"{% endif %}
{% block form_classes %}
Expand Down
2 changes: 1 addition & 1 deletion templates/forms/fields/checkbox/checkbox.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{% endblock %}

{% block input %}
<div class="form-input-wrapper {{ field.size }}">
<div class="form-input-wrapper {{ field.size }} {{ field.wrapper_classes }}">
<input
{# required attribute structures #}
name="{{ (scope ~ field.name)|fieldName }}"
Expand Down
3 changes: 2 additions & 1 deletion templates/forms/fields/checkboxes/checkboxes.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@
{% set checked = (field.use == 'keys' ? value[key] : key in value) %}
{% set help = (key in field.help_options|keys ? field.help_options[key] : false) %}

<span class="checkboxes">
<span class="checkboxes {{ field.wrapper_classes }}">
<input type="checkbox"
id="{{ id|e }}"
value="{{ val|e }}"
name="{{ (scope ~ field.name)|fieldName ~ '[' ~ name ~ ']' }}"
{% if checked %}checked="checked"{% endif %}
{% if field.classes is defined %}class="{{ field.classes }}" {% endif %}
{% if field.disabled or isDisabledToggleable %}disabled="disabled"{% endif %}
{% if field.validate.required %}required="required"{% endif %}
>
Expand Down
3 changes: 2 additions & 1 deletion templates/forms/fields/file/file.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@
{% block input %}
{% set page_can_upload = exists or (type == 'page' and not exists and not (field.destination starts with '@self' or field.destination starts with 'self@')) %}

{% set settings = {name: field.name, paramName: (scope ~ field.name)|fieldName ~ (files.multiple ? '[]' : ''), limit: limit, filesize: files.filesize, accept: files.accept} %}

{% set settings = {name: field.name, paramName: (scope ~ field.name)|fieldName ~ (files.multiple ? '[]' : ''), limit: limit, filesize: (config.system.media.upload_limit / 1024 / 1024), accept: files.accept} %}
<div class="form-input-wrapper dropzone files-upload form-input-file {{ field.size }}" data-grav-file-settings="{{ settings|json_encode|e('html_attr') }}">
<input
{# required attribute structures #}
Expand Down
3 changes: 2 additions & 1 deletion templates/forms/fields/radio/radio.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@
{% for key, text in field.options %}
{% set id = field.id|default(field.name) ~ '-' ~ key %}

<span class="radio">
<span class="radio {{ field.wrapper_classes }}">
<input type="radio"
value="{{ key|e }}"
id="{{ id|e }}"
name="{{ (scope ~ field.name)|fieldName }}"
{% if field.classes is defined %}class="{{ field.classes }}" {% endif %}
{% if key == value %}checked="checked" {% endif %}
{% if field.disabled or isDisabledToggleable %}disabled="disabled"{% endif %}
{% if field.validate.required in ['on', 'true', 1] %}required="required"{% endif %}
Expand Down

0 comments on commit acb8f77

Please sign in to comment.