Fixed column and section fields loosing user entered value when form submit fails

This commit is contained in:
Matias Griese
2020-03-03 13:08:15 +02:00
parent 110584a9b0
commit 3cc76877b2
8 changed files with 12 additions and 11 deletions

View File

@@ -10,6 +10,7 @@
* Improved configuration fields for hiding page types in Admin
1. [](#bugfix)
* Fixed minor UI padding in Flex pages [#1825](https://github.com/getgrav/grav-plugin-admin/issues/1825)
* Fixed `column` and `section` fields loosing user entered value when form submit fails
# v1.10.0-rc.6
## 02/11/2020

View File

@@ -5,7 +5,7 @@
<div class="form-column block pure-u-1-{{ cols }}">
{% for child in field.fields %}
{% if child.type and not child.validate.ignore %}
{% set value = child.name ? data.value(child.name) : data.toArray %}
{% set value = child.name ? (form.value(field.name) ?? data.value(field.name)) : data.toArray %}
{% include ["forms/fields/#{child.type}/#{child.type}.html.twig", 'forms/fields/text/text.html.twig'] with {field: child} %}
{% endif %}
{% endfor %}

View File

@@ -14,7 +14,7 @@
{% if depth > 0 %}
{% set section_value = context.access.get(section.name)|string %}
{% set data = {
{% set params = {
context: context,
action_label: section_label,
action_value: section_value,
@@ -23,7 +23,7 @@
}
%}
{{ macro.action_row(data) }}
{{ macro.action_row(params) }}
{% endif %}
<fieldset>
@@ -51,7 +51,7 @@
{% set action_label = action.label ?? action.name %}
{% set action_value = context.access.get(action.name)|string %}
{% set data = {
{% set params = {
context: context,
action_label: action_label,
action_value: action_value,
@@ -60,7 +60,7 @@
}
%}
{{ macro.action_row(data) }}
{{ macro.action_row(params) }}
{% endmacro %}
{% macro action_row(data) %}

View File

@@ -15,7 +15,7 @@
<div class="form-section {{ field.field_classes }} {{ field.outer_classes }}">
{% for field in field.fields %}
{% if field.type %}
{% set value = field.name ? data.value(field.name) : data.toArray %}
{% set value = field.name ? (form.value(field.name) ?? data.value(field.name)) : data.toArray %}
{% include ["forms/fields/#{field.type}/#{field.type}.html.twig", 'forms/fields/text/text.html.twig'] %}
{% endif %}
{% endfor %}

View File

@@ -4,7 +4,7 @@
<form id="{{ form_id }}" method="post" data-grav-form="{{ form_id }}" data-grav-keepalive="true">
{% for field in blueprints.fields %}
{% if field.type %}
{% set value = field.name ? data.value(field.name) : data.toArray %}
{% set value = field.name ? (form.value(field.name) ?? data.value(field.name)) : data.toArray %}
<div class="block block-{{field.type}}">
{% include ["forms/fields/#{field.type}/#{field.type}.html.twig", 'forms/fields/text/text.html.twig'] %}
</div>

View File

@@ -1,10 +1,10 @@
{% set form_id = form_id ? form_id : 'blueprints' %}
{% set scope = scope ?: 'data.' %}
<form id="{{ form_id }}" method="post" data-grav-form="{{ form_id }}" data-grav-keepalive="true">
<form id="{{ form_id }}" method="post" data-grav-form="{{ form_id }}" {% if form.novalidate %}novalidate{% endif %} data-grav-keepalive="true">
{% for field in blueprints.fields %}
{% if field.type %}
{% set value = field.name ? data.value(field.name) : data.toArray %}
{% set value = field.name ? (form.value(field.name) ?? data.value(field.name)) : data.toArray %}
<div class="block block-{{field.type}}">
{% include ["forms/fields/#{field.type}/#{field.type}.html.twig", 'forms/fields/text/text.html.twig'] %}
</div>

View File

@@ -7,7 +7,7 @@
{% set multipart = ' enctype="multipart/form-data"' %}
{% endif %}
<form id="{{ form_id }}" method="post" data-grav-form="{{ form_id }}" data-grav-keepalive="true"{{ multipart|raw }}>
<form id="{{ form_id }}" method="post" data-grav-form="{{ form_id }}" {% if form.novalidate %}novalidate{% endif %} data-grav-keepalive="true"{{ multipart|raw }}>
{% for field in blueprints.fields %}
{% if field.type %}
{% set value = field.name ? (form.value(field.name) ?? data.value(field.name)) : data.toArray %}

View File

@@ -8,7 +8,7 @@
{% for field in blueprints.fields %}
{% if field.type %}
{% set value = field.name ? data.value(field.name) : data.toArray %}
{% set value = field.name ? (form.value(field.name) ?? data.value(field.name)) : data.toArray %}
<div class="block block-{{field.type}}">
{% include ["forms/fields/#{field.type}/#{field.type}.html.twig", 'forms/fields/text/text.html.twig'] %}
</div>