Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for cols,rows and size attribute, default type is text and label can be ommited #16

Merged
merged 5 commits into from
Nov 12, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion templates/forms/default/form.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
{% for field in form.fields %}
{% set value = form.value(field.name) %}
<div>
{% include "forms/fields/#{field.type}/#{field.type}.html.twig" %}
{% include "forms/fields/#{field.type|default('text')}/#{field.type|default('text')}.html.twig" %}
</div>
{% endfor %}

Expand Down
5 changes: 3 additions & 2 deletions templates/forms/field.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
<label class="inline">
{% block label %}
{% if field.help %}
<span class="tooltip" data-asTooltip-position="w" title="{{ field.help|e }}">{{ field.label }}</span>
<span class="tooltip" data-asTooltip-position="w" title="{{ field.help|e }}">{{ field.label|default(field.name|capitalize) }}</span>
{% else %}
{{ field.label }}
{{ field.label|default(field.name|capitalize) }}
{% endif %}
{{ field.validate.required in ['on', 'true', 1] ? '<span class="required">*</span>' }}
{% endblock %}
Expand Down Expand Up @@ -43,6 +43,7 @@
{% if field.novalidate in ['on', 'true', 1] %}novalidate="novalidate"{% endif %}
{% if field.readonly in ['on', 'true', 1] %}readonly="readonly"{% endif %}
{% if field.autocomplete in ['on', 'off'] %}autocomplete="{{ field.autocomplete }}"{% endif %}
{% if field.size %}size="{{ field.size }}"{% endif %}
{% if field.validate.required in ['on', 'true', 1] %}required="required"{% endif %}
{% if field.validate.pattern %}pattern="{{ field.validate.pattern }}"{% endif %}
{% if field.validate.message %}title="{{ field.validate.message|e|t }}"
Expand Down
4 changes: 3 additions & 1 deletion templates/forms/fields/textarea/textarea.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

{% block input %}
<div class="form-textarea-wrapper {{ field.size }}">
<textarea class="input" name="{{ (scope ~ field.name)|fieldName }}"
<textarea class="input"
{# required attribute structures #}
name="{{ (scope ~ field.name)|fieldName }}"
{# input attribute structures #}
Expand All @@ -19,6 +19,8 @@
{% if field.validate.required in ['on', 'true', 1] %}required="required"{% endif %}
{% if field.validate.pattern %}pattern="{{ field.validate.pattern }}"{% endif %}
{% if field.validate.message %}title="{% if grav.twig.twig.filters['tu'] is defined %}{{ field.validate.message|tu }}{% else %}{{ field.validate.message|t }}{% endif %}"{% endif %}
{% if field.rows is defined %}rows="{{ field.rows }}"{% endif %}
{% if field.cols is defined %}cols="{{ field.cols }}"{% endif %}
{% endblock %}
>{{ value|trim|e('html') }}</textarea>
</div>
Expand Down