webseite-grav/plugins/admin/themes/grav/templates/partials/blueprints.html.twig

38 lines
1.6 KiB
Twig
Raw Normal View History

2021-04-30 11:23:26 +02:00
{% set blueprints = blueprints ?? form.blueprint %}
{% set data = data ?? form.data %}
{% set form_id = form_id ?? 'blueprints' %}
{% set scope = scope ?: 'data.' %}
{% if admin.findFormFields('file', blueprints.fields) %}
{% set multipart = ' enctype="multipart/form-data"' %}
{% endif %}
<form {% if form_action %}action="{{ form_action }}"{% endif %} 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 %}
<div class="block block-{{ field.type }}">
{% include ["forms/fields/#{field.type}/#{field.type}.html.twig", 'forms/fields/text/text.html.twig'] %}
</div>
{% endif %}
{% endfor %}
{% if data.extra %}
{% for name, value in data.extra %}
{% if name not in ['_json','task','admin-nonce'] %}
{% set field = {name: '_json.' ~ name} %}
{% set value = value|json_encode %}
{% include 'forms/fields/hidden/hidden.html.twig' %}
{% endif %}
{% endfor %}
{% endif %}
{% if form %}
{% include "forms/fields/formname/formname.html.twig" %}
{% include 'forms/fields/uniqueid/uniqueid.html.twig' %}
{{ nonce_field(form.getNonceAction(), form.getNonceName())|raw }}
{% else %}
{{ nonce_field('admin-form', 'admin-nonce')|raw }}
{% endif %}
</form>