在Twig / Symfony中形成主题

时间:2017-11-07 12:01:24

标签: symfony twig symfony-3.3

使用Symfony和Twig,我有这个表单和这个表单主题:

TrainingVersionType (这是收藏品)

class TrainingVersionType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->add('name', null, [
                'attr' => [
                    'autofocus' => true,
                ],
                'label' => 'label.training_name',
                'ico' => 'pencil',
                'translation_domain' => 'administration',
            ])
            ->add('document', FineUploaderType::class, [
                'label' => 'label.attachments',
                'translation_domain' => 'administration',
                'limit' => 1,
                'acceptFiles' => [
                    'image/jpeg',
                    'image/png',
                ],
                'allowedExtensions' => [
                    'jpg',
                    'jpeg',
                    'png',
                ],
            ])
        ;
    }

我的Twig文件中的表单主题:

{% block _training_versions_entry_name_widget %}
    <strong style="background: red; padding: 20px">
        Ok 1 :)
    </strong>
{% endblock %}

{% block _training_versions_entry_document_widget %}
    <strong style="background: blue; padding: 20px">
        Ok 2 :)
    </strong>
{% endblock %}

为什么我有&#34;好的1&#34;我没有&#34; OK 2&#34;吗

enter image description here

在我的config.yml中,我有这个全局表单主题,但这是Widget for&#34; FineUploaderType&#34; :

{% block fineuploader_widget %}
    <div class="qq-uploader-selector card mb-3 bg-light">
        <div class="card-body">
            <div class="qq-upload-button-selector">
                <span class="btn btn-info">
                    {{ 'action.select'|trans({}, 'fineuploader') }}
                </span>
            </div>
        </div>
    </div>
    ....
{% endblock %}

我想在&#34;文档&#34;中添加div表单中的条目,用于在FineUploader小部件之后添加帮助。

你能帮帮我吗? :)谢谢

修改:

administration/training/new.html.twig

{% form_theme form 'administration/training/_form_theme.html.twig' %}

{% block content %}
    {{ include('default/page/_new.html.twig', {
            form: form,
            btn_ico: 'plus',
            btn_value: 'action.training_new'|trans({}, 'administration'),
            back_label: 'action.training_back'|trans({}, 'administration'),
            back_path: path('administration_training')
        },
        with_context = false
    ) }}
{% endblock %}

administration/training/_form_theme.html.twig

{% block _training_versions_entry_name_widget %}
    <strong style="background: red; padding: 20px">
        Ok 1 :)
    </strong>
{% endblock %}

{% block _training_versions_entry_document_widget %}
    <strong style="background: blue; padding: 20px">
        Ok 2 :)
    </strong>
{% endblock %}

0 个答案:

没有答案