Fixed editor discarding existing content when failing, closes #112.

This commit is contained in:
flash 2019-01-01 04:48:48 +01:00
parent f3b02edfaa
commit b84b4475fc
2 changed files with 20 additions and 4 deletions

View file

@ -239,4 +239,10 @@ echo tpl_render('forum.posting', [
'posting_notices' => $notices, 'posting_notices' => $notices,
'posting_mode' => $mode, 'posting_mode' => $mode,
'posting_types' => $topicTypes, 'posting_types' => $topicTypes,
'posting_defaults' => [
'title' => $topicTitle ?? null,
'type' => $topicType ?? null,
'text' => $postText ?? null,
'parser' => $postParser ?? MSZ_PARSER_BBCODE,
],
]); ]);

View file

@ -17,7 +17,7 @@
: input_text( : input_text(
'post[title]', 'post[title]',
'forum__header__input', 'forum__header__input',
posting_topic.topic_title|default(''), posting_defaults.title|default(posting_topic.topic_title|default('')),
'text', 'text',
'Enter your title here...' 'Enter your title here...'
), ),
@ -62,13 +62,23 @@
</div> </div>
<div class="forum__post__content"> <div class="forum__post__content">
<textarea name="post[text]" class="forum__post__text forum__post__text--edit" placeholder="Type your post content here...">{{ posting_post.post_text|default('') }}</textarea> <textarea name="post[text]" class="forum__post__text forum__post__text--edit" placeholder="Type your post content here...">{{ posting_defaults.text|default(posting_post.post_text|default('')) }}</textarea>
<div class="forum__post__options"> <div class="forum__post__options">
<div class="forum__post__settings"> <div class="forum__post__settings">
{{ 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 %} {% 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 %} {% endif %}
</div> </div>