{% extends '@RxConnexion/Admin/content.html.twig' %}
{% block content %}
    <form method="POST" action="{{ path('faq_form', {action: action, id: id}) }}" enctype="multipart/form-data">
        <div class="row max-width-initial">
            <div class="large-6 columns">
                <h5>Basic information</h5>
                <p class="form-hint-text">Enter basic information below</p>
                <div class="row">
                    <div class="large-3 large-text-right columns">
                        {{ form_label(form.fileType_desc) }}
                    </div>
                    <div class="large-9 columns">
                        {{ form_widget(form.fileType_desc) }}
                        {{ form_widget(form.fileType) }}
                    </div>
                </div>
                <div class="row">
                    <div class="large-3 large-text-right columns">
                        {{ form_label(form.description) }}
                    </div>
                    <div class="large-9 columns">
                        {{ form_widget(form.description) }}
                    </div>
                </div>
                <div class="row">
                    <div class="large-3 large-text-right columns">
                        {{ form_label(form.note) }}
                    </div>
                    <div class="large-9 columns">
                        {{ form_widget(form.note) }}
                    </div>
                </div>
            </div>
            <div class="large-6 columns">
                <h5>Attachments(s) <a href="javascript:void(0)" id="href-new-file-field"><i class="fa fa-plus"></i></a></h5>
                <p class="form-hint-text">Upload file(s) below</p>
                <div id="file-field-container">
                    {% if faq %}
                        {% for key,ff in faq.frequentlyAskedQuestionFiles %}
                            {% if ff.isDeleted != true %}
                                <div class="input-group no-margin-bottom">
                                    <input type="hidden" name="otherForm[files][{{ key }}]" value="{{ ff.idencoded }}" />
                                    <a href="{{ path('faq_file_download', {faq_id: ff.idencoded}) }}">{{ ff.filedesc }}</a>
                                    <div class="input-group-button">
                                        <button type="button" class="button secondary file-field-remove"><i class="fa fa-remove"></i></button>
                                    </div>
                                </div>
                            {% endif %}
                        {% endfor %}
                    {% endif %}
                </div>
            </div>
            <div class="small-12 columns">
                <hr class="max-width-initial">
                <div class="button-container">
                    <button type="submit" class="button just-continue" name="action" value="{{ action }}"
                            data-message="Are you sure you want to save this information?"
                    >Save</button>
                    {% if action == 'u' and (userData.type == 'Super Admin' or 'Admin Faq Delete' in userData.accesses) %}
                        <button type="submit" class="ask-continue button alert" name="action" value="d"
                                data-message="Are you sure you want to delete this record?"
                        >Delete</button>
                    {% endif %}
                    <a href="{{ path('faq') }}" class="button secondary">Back</a>
                </div>
            </div>
        </div>
        {{ form_widget(form.action) }}
        {{ form_widget(form.id) }}
        {{ form_widget(form._token) }}
    </form>
    {% include '@RxConnexion/Admin/js.html.twig' %}
    <script>
        //<![CDATA[
        faq_form.settings.fileType_autocomplete_url = '{{ path('file_type_autocomplete') }}';
        jQ(document).ready(function(){
            faq_form.init();
        });
        //]]>
    </script>
{% endblock %}