Skip to content

Commit

Permalink
Merge branch 'release/4.0.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
rhukster committed Feb 3, 2020
2 parents e090e82 + 9a472ff commit 647f14b
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 8 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
# v4.0.2
## 02/03/2020

1. [](#improved)
* Allow checkbox field to have custom value, default to 1
1. [](#bugfix)
* Fixed `toggle` field not working with `toggleable: true`
* Fixed fatal error when form type is disabled

# v4.0.1
## 01/02/2020

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: 4.0.1
version: 4.0.2
testing: false
description: Enables the forms handling
icon: check-square
Expand Down
8 changes: 6 additions & 2 deletions form.php
Original file line number Diff line number Diff line change
Expand Up @@ -712,10 +712,14 @@ public function onFormValidationError(Event $event)
* Add a form to the forms plugin
*
* @param string|null $page_route
* @param FormInterface $form
* @param FormInterface|null $form
*/
public function addForm(?string $page_route, FormInterface $form)
public function addForm(?string $page_route, ?FormInterface $form)
{
if (null === $form) {
return;
}

$name = $form->getName();

if (!isset($this->forms[$page_route][$name])) {
Expand Down
4 changes: 2 additions & 2 deletions templates/forms/fields/checkbox/checkbox.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
<input
{# required attribute structures #}
name="{{ (scope ~ field.name)|fieldName }}"
value="{{ value|join(', ') }}"
value="{{ field.value ?? '1' }}"
type="checkbox"
{% if value == true %} checked="checked" {% endif %}
{% if value == field.value ?? '1' %} checked="checked" {% endif %}

{# input attribute structures #}
{% block input_attributes %}
Expand Down
4 changes: 1 addition & 3 deletions templates/forms/fields/toggle/toggle.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@

{% import _self as macro %}

{% set value = value ?? field.default %}
{% set value = (value is same as(false) ? 0 : value) %}

{% set has_hidden = false %}
{% for key, text in field.options %}
{% if key is empty %}
Expand All @@ -23,6 +20,7 @@
{% endblock %}

{% block input %}
{% set value = (value is same as(false) ? 0 : value) %}

<div class="switch-toggle switch-grav {{ field.size }} switch-{{ field.options|length }} {{ field.classes }}">
{% set maxLen = 0 %}
Expand Down

0 comments on commit 647f14b

Please sign in to comment.