简体   繁体   English

SonataAdmin-表单集合

[英]SonataAdmin - form collections

I'm trying to embed a Product Variant into my Product admin using SonataAdminBundle . 我正在尝试使用SonataAdminBundleProduct Variant嵌入我的Product管理员中。

So one Product has many Variants 因此, one产品具有many变体

I have the following Entities: 我有以下实体:

Product.php

/**
 * @var ProductVariant $variants
 * @ORM\ManyToMany(targetEntity="ProductVariant", cascade={"persist", "remove"} )
 **/
protected $variants;

ProductVariant.php

/**
 * @ORM\ManyToOne(targetEntity="Product", inversedBy="variants")
 * @ORM\JoinColumn(name="product_id", referencedColumnName="id")
 */
protected $product;

Now, I have the following in my Admin Form class: 现在,我的“管理表单”类中包含以下内容:

        ->add('variants','collection', array(
           'type' =>  new ProductVariantType(),
           'allow_add' => true,
       ), array(
           'edit' => 'inline',
           'inline' => 'table',
       ))

This displays the Add Button to add a new Variant, but after clicking on it, I'd expect the row to be inline and within a table , but these options don't seem to get triggered. 这将显示“添加按钮”以添加新的变体,但是单击它之后,我希望该行是inline并且位于table ,但是这些选项似乎不会被触发。

Thanks 谢谢

Only sonata_type_collection supports options 'edit' and 'inline' . sonata_type_collection支持选项'edit''inline' Not core collection type. 不是核心collection类型。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM