Skip to content

Commit

Permalink
Merge branch 'release/2.2.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
rhukster committed Mar 14, 2017
2 parents 01030a9 + 8f66393 commit 0cba177
Show file tree
Hide file tree
Showing 8 changed files with 78 additions and 31 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
# v2.2.0
## 03/13/2017

1. [](#new)
* 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 disable fields label if not defined [#126](https://github.com/getgrav/grav-plugin-form/issues/126)

# v2.1.1
## 02/17/2017

1. [](#improved)
* Better default output for select, checkbox and checkboxes fields in the form destination page and in the emails sent via form submit [#121](https://github.com/getgrav/grav-plugin-form/issues/121)


# v2.1.0
## 02/10/2017

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.1.1
version: 2.2.0
description: Enables the forms handling
icon: check-square
author:
Expand Down
26 changes: 14 additions & 12 deletions templates/forms/default/field.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,20 @@
{% block field %}
<div class="form-field {% if field.outerclasses is defined %} {{ field.outerclasses }}{% endif %}{% if errors %} has-errors{% endif %} {% block outer_field_classes %}{% endblock %}">
{% block contents %}
<div class="form-label">
<label class="inline" {% if field.id is defined %}for="{{ field.id|e }}" {% endif %} >
{% block label %}
{% if field.help %}
<span class="tooltip" data-asTooltip-position="w" title="{{ field.help|t|e }}">{{ field.label|default(field.name|capitalize)|t }}</span>
{% else %}
{{ field.label|default(field.name|capitalize)|t }}
{% endif %}
{{ field.validate.required in ['on', 'true', 1] ? '<span class="required">*</span>' }}
{% endblock %}
</label>
</div>
{% if field.label is not same as(false) %}
<div class="form-label">
<label class="inline" {% if field.id is defined %}for="{{ field.id|e }}" {% endif %} >
{% block label %}
{% if field.help %}
<span class="tooltip" data-asTooltip-position="w" title="{{ field.help|t|e }}">{{ field.label|default(field.name|capitalize)|t }}</span>
{% else %}
{{ field.label|default(field.name|capitalize)|t }}
{% endif %}
{{ field.validate.required in ['on', 'true', 1] ? '<span class="required">*</span>' }}
{% endblock %}
</label>
</div>
{% endif %}
<div class="form-data"
{% block global_attributes %}
data-grav-field="{{ field.type }}"
Expand Down
34 changes: 18 additions & 16 deletions templates/forms/default/form.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -49,22 +49,24 @@
{% endblock %}

{% for button in form.buttons %}
{% if button.url %}
<a href="{{ button.url starts with 'http' ? button.url : url(button.url) }}">
{% endif %}
<button
{% if button.id %}id="{{ button.id }}"{% endif %}
{% block button_classes %}
class="{{ button.classes|default('button') }}"
{% endblock %}
{% if button.disabled %}disabled="disabled"{% endif %}
type="{{ button.type|default('submit') }}"
>
{{ button.value|t|default('Submit') }}
</button>
{% if button.url %}
</a>
{% endif %}
<div class="{% if button.outerclasses is defined %} {{ button.outerclasses }}{% endif %}">
{% if button.url %}
<a href="{{ button.url starts with 'http' ? button.url : url(button.url) }}">
{% endif %}
<button
{% if button.id %}id="{{ button.id }}"{% endif %}
{% block button_classes %}
class="{{ button.classes|default('button') }}"
{% endblock %}
{% if button.disabled %}disabled="disabled"{% endif %}
type="{{ button.type|default('submit') }}"
>
{{ button.value|t|default('Submit') }}
</button>
{% if button.url %}
</a>
{% endif %}
</div>
{% endfor %}

{% block inner_markup_buttons_end %}
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 @@ -24,6 +24,6 @@
{% endblock %}
/>

<label class="inline"{% if field.id is defined %} for="{{ field.id|e }}"{% endif %}>{{ field.label|t|e }} {{ field.validate.required in ['on', 'true', 1] ? '<span class="required">*</span>' }}</label>
<label style="display:inline;" class="inline"{% if field.id is defined %} for="{{ field.id|e }}"{% endif %}>{{ field.label|t|e }} {{ field.validate.required in ['on', 'true', 1] ? '<span class="required">*</span>' }}</label>
</div>
{% endblock %}
18 changes: 18 additions & 0 deletions templates/forms/fields/conditional/conditional.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{% if evaluate(field.condition) == 'true' %}
{% if field.classes %}
<div class="{{ field.classes }}">
{% endif %}

{% if field.fields %}
{% for field in field.fields %}
{% if field.type %}
{% set value = data.value(field.name) %}
{% include ["forms/fields/#{field.type}/#{field.type}.html.twig", 'forms/fields/text/text.html.twig'] %}
{% endif %}
{% endfor %}
{% endif %}

{% if field.classes %}
</div>
{% endif %}
{% endif %}
14 changes: 14 additions & 0 deletions templates/forms/fields/fieldset/fieldset.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<fieldset {% if field.id is defined %}id="{{ field.id }}"{% endif %} {% if field.classes is defined %}class="{{ field.classes }}" {% endif %}>
{% if field.legend %}
<legend>{% if grav.twig.twig.filters['tu'] is defined %}{{ field.legend|tu }}{% else %}{{ field.legend|t }}{% endif %}</legend>
{% endif %}

{% if field.fields %}
{% for field in field.fields %}
{% if field.type %}
{% set value = data.value(field.name) %}
{% include ["forms/fields/#{field.type}/#{field.type}.html.twig", 'forms/fields/text/text.html.twig'] %}
{% endif %}
{% endfor %}
{% endif %}
</fieldset>
2 changes: 1 addition & 1 deletion templates/forms/fields/radio/radio.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
{% if field.disabled or isDisabledToggleable %}disabled="disabled"{% endif %}
{% if field.validate.required in ['on', 'true', 1] %}required="required"{% endif %}
/>
<label style="display: inline" for="{{ id|e }}">{{ text|e }}</label>
<label style="display: inline" class="inline" for="{{ id|e }}">{{ text|e }}</label>
</span>
{% endfor %}
{% endblock %}

0 comments on commit 0cba177

Please sign in to comment.