Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/80.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Symfony 2实体表单字段_Php_Html_Symfony_Twig - Fatal编程技术网

Php Symfony 2实体表单字段

Php Symfony 2实体表单字段,php,html,symfony,twig,Php,Html,Symfony,Twig,我有一个带有实体字段的细枝模板,当我使用它两次时,它就不起作用了。例如: <div class="control-group"> <label class="control-label">Secondary</label> <div class="controls"> {% if entity.category and entity.category.parent %} <span st

我有一个带有实体字段的细枝模板,当我使用它两次时,它就不起作用了。例如:

<div class="control-group">
    <label class="control-label">Secondary</label>
    <div class="controls">
        {% if entity.category and entity.category.parent %}
            <span style="margin-right:5px;">{{ entity.category.parent.name }} ›</span>
        {% endif %}
        {{ form_errors(edit_form.categories) }}
        {{ form_widget(edit_form.categories) }}
    </div>
</div>

次要的
{%if entity.category和entity.category.parent%}
{{entity.category.parent.name}}›
{%endif%}
{{form_errors(edit_form.categories)}
{{form_小部件(编辑_form.categories)}
如果我这样做:

<div class="control-group">
    <label class="control-label">Secondary</label>
    <div class="controls">
        {% if entity.category and entity.category.parent %}
            <span style="margin-right:5px;">{{ entity.category.parent.name }} ›</span>
        {% endif %}
        {{ form_errors(edit_form.categories) }}
        {{ form_widget(edit_form.categories) }}
    </div>
</div>
<div class="control-group">
    <label class="control-label">Secondary 2</label>
    <div class="controls">
        {% if entity.category and entity.category.parent %}
            <span style="margin-right:5px;">{{ entity.category.parent.name }} ›</span>
        {% endif %}
        {{ form_errors(edit_form.categories) }}
        {{ form_widget(edit_form.categories) }}
    </div>
</div>

次要的
{%if entity.category和entity.category.parent%}
{{entity.category.parent.name}}›
{%endif%}
{{form_errors(edit_form.categories)}
{{form_小部件(编辑_form.categories)}
中二
{%if entity.category和entity.category.parent%}
{{entity.category.parent.name}}›
{%endif%}
{{form_errors(edit_form.categories)}
{{form_小部件(编辑_form.categories)}

标签已写入,但无法获取“选择标签”框。经过研究,我得出结论:复制实体是不可能的?

当我这样做时,你需要使用:表单的视图数据应该是类的实例。你需要创建一个表单,为实体保存表单。这样,您就可以为实体类型的多个实例指定一个表单