{% 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.back(url('/questions')) }} {{ block('title') }}

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

{{ m.icon('clock') }} {{ question.updated_at.format(__('general.datetime')) }} {% if question.updated_at != question.created_at %}  {{ __('form.updated') }}
{{ m.icon('clock') }} {{ question.created_at.format(__('general.datetime')) }} {% 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(__('form.save'), {'icon_left': 'save'}) }} {% if is_admin|default(false) %} {{ f.submit(m.icon('eye'), {'name': 'preview', 'btn_type': 'info', 'title': __('form.preview')}) }} {% if question and question.id %} {{ f.delete(__('form.delete'), {'confirm_title': __('question.delete.title', [question.text[:40]|e])}) }} {% endif %} {% endif %}
{% if question %}

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

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