[% title = faq.in_storage ? "Edit FAQ entry" : "Create new FAQ entry" %]

[% IF faq %]
    <p><a href="[% faq.url %]">Show existing FAQ entry</a></p>
[% END %]

<form method="post" action="[% submit_url %]">
    <!-- URL fragment format regex taken from https://stackoverflow.com/a/26119120/498634 -->
    <p>HTML anchor name: <input type="text" name="anchor" pattern="([-?/:@._~!$&'()*+,;=a-zA-Z0-9]|%[0-9a-fA-F]{2})*" value="[% faq.anchor | html %]"></p>

    <h3>Question</h3>
    <div class="row mb-2">
        <div class="col-sm-6 mb-sm-0 mb-2">
            <input class="form-control with-markdown-preview" type="text" name="question" value="[% faq.question_md | html %]">
        </div>
    </div>
    

    <h3>Answer</h3>
    <div class="row mb-2">
        <div class="col-sm-6 mb-sm-0 mb-2">
            <textarea class="form-control with-markdown-preview" name="answer" rows="10">[% faq.answer_md | html %]</textarea>
        </div>
    </div>
    

    <p><input type="submit" value="[% faq.in_storage ? 'Update' : 'Create' %]"></p>
</form>
