实体定义
/**
* @var ArrayCollection|Keyword
* @ORM\ManyToMany(targetEntity="Mea\KeywordsBundle\Entity\Keyword",cascade={"persist"})
* @ORM\JoinTable(
* joinColumns={@ORM\JoinColumn(name="log_id", referencedColumnName="id")},
* inverseJoinColumns={@ORM\JoinColumn(name="keyword_id", referencedColumnName="id")}
* )
*/
protected $tags;
管理员定义
protected function configureListFields(ListMapper $listMapper)
{
->add('tags','many_to_one',[
'editable' => true,
'multiple'=>true,
'class' => Keyword::class,
])
该字段不可编辑-标签显示为href,以编辑一个标签。
我在奏鸣曲模板中搜索供应商/sonata-project/admin-bundle/src/Resources/views/CRUD/base_list_field.html.twig-此字段为true,但xEditableType为null。
答案 0 :(得分:0)
如您在github存储库中所见,多对一列表字段根本不可编辑。
editable => true
不执行任何操作,而multiple => true
则无用,因为它与许多一对关系...
这是此列表字段的代码:
{% block field %}
{% if value %}
{% set route_name = field_description.options.route.name %}
{% if not field_description.options.identifier|default(false)
and field_description.hasAssociationAdmin
and field_description.associationadmin.hasRoute(route_name)
and field_description.associationadmin.hasAccess(route_name, value)
and field_description.associationadmin.id(value)
%}
<a href="{{ field_description.associationadmin.generateObjectUrl(route_name, value, field_description.options.route.parameters) }}">
{{ value|render_relation_element(field_description) }}
</a>
{% else %}
{{ value|render_relation_element(field_description) }}
{% endif %}
{% endif %}
{% endblock %}