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

Uses Craft's native fieldLayout createForm() for edit screen. #25

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
30 changes: 10 additions & 20 deletions src/templates/_edit.twig
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
{% extends "_layouts/cp" %}
{% import "_includes/forms" as forms %}

{% set element = tag %}

{% set form = element.getFieldLayout().createForm(element) %}

{% if tabs is not defined %}
{% set tabs = form.getTabMenu() %}
{% endif %}

{% block contextMenu %}
{% if craft.app.getIsMultiSite() %}
<div class="btn menubtn sitemenubtn"
Expand Down Expand Up @@ -92,25 +100,7 @@
<input type="hidden" name="siteId" value="{{ tag.siteId }}">
{% endif %}

<div id="fields">
{{ forms.textField({
label: 'Title'|t('app'),
siteId: tag.siteId,
id: 'title',
name: 'title',
value: tag.title,
errors: tag.getErrors('title'),
first: true,
autofocus: true,
required: true,
maxlength: 255
}) }}

{% include "_includes/fields" with {
fields: tag.group.getFieldLayout().getFields(),
element: tag,
} only %}
</div>
{{ form.render()|raw }}
{% endblock %}

{% block details %}
Expand Down Expand Up @@ -169,4 +159,4 @@
charMap: {{ craft.cp.getAsciiCharMap(tag.site.language)|json_encode|raw }}
});
{% endjs %}
{% endif %}
{% endif %}