Almost. It has 2 important problems.
1) Tags block is not correct for the user editor page
This template is for editorial_edit.html used by users on:
- /editorial/new
- /editorial/{article_id}/edit
But your user routes do not pass:
- tags
- selected_tag_ids
So this block can fail or stay empty:
<div style="color:red;">Tags count: {{ tags|length }}</div> ... {% for t in tags %}Best fix
Either remove tags from the user page, or make it safe:
{% if tags is defined and tags %} <div> <label style="font-weight:900;">Tags</label> <select name="tag_ids" multiple style="padding:10px;border:1px solid #ddd;border-radius:10px;height:140px;"> {% for t in tags %} <option value="{{ t.id }}" {% if selected_tag_ids is defined and t.id in selected_tag_ids %}selected{% endif %}> {{ t.name }} </option> {% endfor %} </select> <div style="font-size:12px;color:#666;margin-top:6px;"> Hold Ctrl / Cmd to select multiple tags </div> </div> {% endif %}Recommended
Keep tags only in admin edit page, not user page.
2) Autosave route does not save tags anyway
In your JS autosave you only send:
fd.append("article_id", articleId); fd.append("title", title); fd.append("body", bodyHtml); fd.append("language", language);No tags are sent. So even if tags are shown in this page, autosave ignores them.
Correct version for this user template
For editorial_edit.html, the clean version is to remove the tags block completely.
So remove this whole section:
<div> <label style="font-weight:900;">Tags</label> <div style="color:red;">Tags count: {{ tags|length }}</div> <select name="tag_ids" multiple style="padding:10px;border:1px solid #ddd;border-radius:10px;height:140px;"> {% for t in tags %} <option value="{{ t.id }}" {% if t.id in selected_tag_ids %}selected{% endif %}> {{ t.name }} </option> {% endfor %} </select> <div style="font-size:12px;color:#666;margin-top:6px;"> Hold Ctrl / Cmd to select multiple tags </div> </div>What should remain there
Your user form should keep only:
- Title
- Language
- Action
- Article text
- Upload
- Save
That is correct.
Your autosave fix is correct
This part is good:
if (data.article_id && !articleId) { articleIdInput.value = data.article_id; form.action = `/editorial/${data.article_id}/edit`; }Keep it.
Final answer
So:
- No, this template is not fully correct as written
- the Tags block should be removed from this user page
- tags should stay in admin_editorial_edit.html
If you want, I can give you the final cleaned editorial_edit.html with the tags block removed.
گفتگو