fixed conflict between textarea require and tinymce

This commit is contained in:
julien
2026-02-23 16:49:45 +01:00
parent fd0f7d2bf9
commit c4acb5226c

View File

@@ -17,20 +17,23 @@
{% endif %}
</h2>
<form method="post" action="{{ action }}">
{# Formulaire identifié pour le script JavaScript #}
<form id="articleForm" method="post" action="{{ action }}">
<p>
<label>Titre<br>
<input type="text" name="title"
value="{{ post.title|default('') }}" required>
</label>
</p>
<p>
<label>Contenu<br>
<textarea id="editor" name="content" rows="6" required>{{ post.content|default('') }}</textarea>
<textarea id="editor" name="content" rows="6" {# required <- removed because conflicts with TinyMCE#}>{{ post.content|default('') }}</textarea>
</label>
</p>
<button type="submit">
{% if post is defined %}Mettre à jour{% else %}Enregistrer{% endif %}
{% if post is defined and post.id is defined %}Mettre à jour{% else %}Enregistrer{% endif %}
</button>
</form>
@@ -38,23 +41,27 @@
{% endblock %}
{% block scripts %}
{# TinyMCE #}
<script src="/js/tinymce/tinymce.min.js" referrerpolicy="origin" crossorigin="anonymous"></script>
<script>
tinymce.init({
selector: '#editor', // id du textarea
license_key: 'gpl', // self-host TinyMCE under the GPL license and agree to its terms
selector: '#editor',
base_url: '/js/tinymce', // assure le bon chemin relatif
license_key: 'gpl',
height: 400,
menubar: false,
plugins: [
'advlist autolink lists link image charmap preview anchor',
'searchreplace visualblocks code fullscreen',
'insertdatetime media table paste code help wordcount'
'advlist', 'autolink', 'lists', 'link', 'image',
'charmap', 'preview', 'anchor', 'searchreplace',
'visualblocks', 'code', 'fullscreen',
'insertdatetime', 'media', 'table',
'help', 'wordcount'
],
toolbar: 'undo redo | formatselect | bold italic underline | ' +
'alignleft aligncenter alignright alignjustify | ' +
'bullist numlist outdent indent | link image media | ' +
'removeformat | help',
toolbar: [
'undo redo | formatselect | bold italic underline |',
'alignleft aligncenter alignright alignjustify |',
'bullist numlist outdent indent | link image media |',
'removeformat | help'
].join(' '),
content_style: 'body {font-family:Helvetica,Arial,sans-serif;font-size:14px}'
});
</script>