Oops, bug fix

This commit is contained in:
Matias Griese
2020-03-03 15:01:17 +02:00
parent 3cc76877b2
commit 9e3f19818d
2 changed files with 11 additions and 5 deletions

View File

@@ -1661,17 +1661,23 @@ class AdminController extends AdminBaseController
}
$route = $data['route'] !== '/' ? $data['route'] : '';
$folder = $data['folder'];
$folder = $data['folder'] ?? null;
$title = $data['title'] ?? null;
// Handle @slugify-{field} value, automatically slugifies the specified field
if (0 === strpos($folder, '@slugify-')) {
$folder = \Grav\Plugin\Admin\Utils::slug($data[substr($folder, 9)]);
if (null !== $folder && 0 === strpos($folder, '@slugify-')) {
$folder = \Grav\Plugin\Admin\Utils::slug($data[substr($folder, 9)] ?? '');
}
if (!$folder) {
$folder = \Grav\Plugin\Admin\Utils::slug($title) ?: '';
}
$folder = ltrim($folder, '_');
if (!empty($data['modular'])) {
$folder = '_' . $folder;
}
$path = $route . '/' . $folder;
$data['folder'] = $folder;
$path = $route . '/' . $folder;
$this->admin->session()->{$path} = $data;
// Store the name and route of a page, to be used pre-filled defaults of the form in the future

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 ? (form.value(field.name) ?? data.value(field.name)) : data.toArray %}
{% set value = child.name ? (form.value(child.name) ?? data.value(child.name)) : data.toArray %}
{% include ["forms/fields/#{child.type}/#{child.type}.html.twig", 'forms/fields/text/text.html.twig'] with {field: child} %}
{% endif %}
{% endfor %}