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 * Improved configuration fields for hiding page types in Admin
1. [](#bugfix) 1. [](#bugfix)
* Fixed minor UI padding in Flex pages [#1825](https://github.com/getgrav/grav-plugin-admin/issues/1825) * 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 # v1.10.0-rc.6
## 02/11/2020 ## 02/11/2020

View File

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

View File

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

View File

@@ -15,7 +15,7 @@
<div class="form-section {{ field.field_classes }} {{ field.outer_classes }}"> <div class="form-section {{ field.field_classes }} {{ field.outer_classes }}">
{% for field in field.fields %} {% for field in field.fields %}
{% if field.type %} {% 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'] %} {% include ["forms/fields/#{field.type}/#{field.type}.html.twig", 'forms/fields/text/text.html.twig'] %}
{% endif %} {% endif %}
{% endfor %} {% endfor %}

View File

@@ -4,7 +4,7 @@
<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 }}" data-grav-keepalive="true">
{% for field in blueprints.fields %} {% for field in blueprints.fields %}
{% if field.type %} {% 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}}"> <div class="block block-{{field.type}}">
{% include ["forms/fields/#{field.type}/#{field.type}.html.twig", 'forms/fields/text/text.html.twig'] %} {% include ["forms/fields/#{field.type}/#{field.type}.html.twig", 'forms/fields/text/text.html.twig'] %}
</div> </div>

View File

@@ -1,10 +1,10 @@
{% set form_id = form_id ? form_id : 'blueprints' %} {% set form_id = form_id ? form_id : 'blueprints' %}
{% set scope = scope ?: 'data.' %} {% 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 %} {% for field in blueprints.fields %}
{% if field.type %} {% 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}}"> <div class="block block-{{field.type}}">
{% include ["forms/fields/#{field.type}/#{field.type}.html.twig", 'forms/fields/text/text.html.twig'] %} {% include ["forms/fields/#{field.type}/#{field.type}.html.twig", 'forms/fields/text/text.html.twig'] %}
</div> </div>

View File

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