{% extends 'layouts/app.twig' %} {% import 'macros/base.twig' as m %} {% import 'macros/form.twig' as f %} {% block title %}{{ question and question.id ? __('question.edit') : __('question.add') }}{% endblock %} {% block content %}

{{ m.button(m.icon('chevron-left'), url('/questions'), null, 'sm') }} {{ block('title') }}

{% include 'layouts/parts/messages.twig' %} {% if question and question.id %}

{{ m.icon('clock') }} {{ question.updated_at.format(__('Y-m-d H:i')) }} {% if question.updated_at != question.created_at %}  {{ __('form.updated') }}
{{ m.icon('clock') }} {{ question.created_at.format(__('Y-m-d H:i')) }} {% endif %}

{% endif %}
{{ csrf() }}
{{ f.textarea('text', __('question.question'), { 'required': true, 'rows': 10, 'value': question ? question.text : '', }) }}
{% if is_admin|default(false) %} {{ f.textarea('answer', __('question.answer'), { 'required': true, 'rows': 10, 'value': question ? question.answer : '', }) }} {% endif %} {{ f.submit() }} {% if is_admin|default(false) %} {{ f.submit(m.icon('eye'), {'name': 'preview', 'btn_type': 'info', 'title': __('form.preview')}) }} {% if question and question.id %} {{ f.submit(m.icon('trash'), {'name': 'delete', 'btn_type': 'danger', 'title': __('form.delete')}) }} {% endif %} {% endif %}
{% if question %}

{{ __('form.preview') }}

{{ question.text|nl2br }}
{% if question.answer %}
{{ question.answer|markdown }}
{% endif %}
{% endif %}
{% endblock %}