From b84b4475fc43b4f37400a729167eb63bf8a96277 Mon Sep 17 00:00:00 2001 From: flashwave Date: Tue, 1 Jan 2019 04:48:48 +0100 Subject: [PATCH] Fixed editor discarding existing content when failing, closes #112. --- public/forum/posting.php | 6 ++++++ templates/forum/posting.twig | 18 ++++++++++++++---- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/public/forum/posting.php b/public/forum/posting.php index 69c421d7..3d26b40f 100644 --- a/public/forum/posting.php +++ b/public/forum/posting.php @@ -239,4 +239,10 @@ echo tpl_render('forum.posting', [ 'posting_notices' => $notices, 'posting_mode' => $mode, 'posting_types' => $topicTypes, + 'posting_defaults' => [ + 'title' => $topicTitle ?? null, + 'type' => $topicType ?? null, + 'text' => $postText ?? null, + 'parser' => $postParser ?? MSZ_PARSER_BBCODE, + ], ]); diff --git a/templates/forum/posting.twig b/templates/forum/posting.twig index 133467ec..55c01960 100644 --- a/templates/forum/posting.twig +++ b/templates/forum/posting.twig @@ -17,7 +17,7 @@ : input_text( 'post[title]', 'forum__header__input', - posting_topic.topic_title|default(''), + posting_defaults.title|default(posting_topic.topic_title|default('')), 'text', 'Enter your title here...' ), @@ -62,13 +62,23 @@
- +
- {{ input_select('post[parser]', constant('MSZ_PARSERS_NAMES'), posting_post.post_parse|default(constant('MSZ_PARSER_BBCODE')), null, null, null, 'forum__post__dropdown') }} + {{ input_select( + 'post[parser]', + constant('MSZ_PARSERS_NAMES'), + posting_defaults.parser|default(posting_post.post_parse|default(constant('MSZ_PARSER_BBCODE'))), + null, null, null, 'forum__post__dropdown' + ) }} {% if is_opening and posting_types|length > 1 %} - {{ input_select('post[type]', posting_types, posting_topic.topic_type|default(posting_types|keys|first), null, null, null, 'forum__post__dropdown') }} + {{ input_select( + 'post[type]', + posting_types, + posting_defaults.type|default(posting_topic.topic_type|default(posting_types|keys|first)), + null, null, null, 'forum__post__dropdown' + ) }} {% endif %}