我想在PageAdmin formMapper中显示我的Product实体的所有实例。我在文档中搜索了类似的东西,却找不到它。有谁知道怎么做?
这是我的PageAdmin
<?php
namespace MyShop\ShopBundle\Admin;
use Sonata\AdminBundle\Admin\Admin;
use Sonata\AdminBundle\Datagrid\ListMapper;
use Sonata\AdminBundle\Datagrid\DatagridMapper;
use Sonata\AdminBundle\Form\FormMapper;
class PageAdmin extends Admin
{
// Fields to be shown on create/edit forms
protected function configureFormFields(FormMapper $formMapper)
{
$formMapper
// ->add('title', 'text', array('label' => 'Post Title'))
// ->add('author', 'entity', array('class' => 'MyShop\UserBundle\Entity\User'))
->add('title', 'text', array('label' => 'Page Title'))
;
}
// Fields to be shown on filter forms
protected function configureDatagridFilters(DatagridMapper $datagridMapper)
{
$datagridMapper
->add('title')
;
}
// Fields to be shown on lists
protected function configureListFields(ListMapper $listMapper)
{
$listMapper
// ->addIdentifier('title')
->add('title')
->add('_action', 'actions', array(
'actions' => array(
'edit' => array(),
)
))
;
}
}
答案 0 :(得分:0)
您可以覆盖此实体的CRUDController,特别是listViewAction,如线程所示:How to process each entity in SonataAdminBundle list view?
如果您需要有关CRUDController覆盖的更多信息,请参阅此页面:http://sonata-project.org/bundles/doctrine-orm-admin/master/doc/tutorial/creating_your_first_admin_class/defining_crud_controller.html