douyaju4749 2014-08-30 12:02
浏览 23

空索纳塔管理实体列表视图

I got a weird result using the Sonata Admin -- list view. Here is the snapshot.

http://i.stack.imgur.com/AGmVI.png


config.yml:

    # ...

sonata_admin:
    title: Administration
    title_logo: extras/fi.gif

sonata_block:
    default_contexts: [cms]
    blocks:
        # Enable the SonataAdminBundle block
        sonata.admin.block.admin_list:
            contexts:   [admin]

services.yml:

# ...

services:
    sonata.department.admin:
        class: %sonata.department.admin.class%
        tags:
            - { name: sonata.admin, manager_type: orm }

DepartmentAdmin.php

<?php

namespace Abc\Bundles\HelloBundle\Admin;

use Sonata\AdminBundle\Admin\Admin;

use Sonata\AdminBundle\Datagrid\ListMapper;
use Sonata\AdminBundle\Datagrid\DatagridMapper;
use Sonata\AdminBundle\Form\FormMapper;

class DepartmentAdmin extends Admin
{
    protected function configureFormFields(FormMapper $formMapper)
    {
        $formMapper
            ->with('Department')
                ->add('name')
            ->end();
    }

    protected function configureDatagridFilter(DatagridMapper $datagridMapper)
    {
        $datagridMapper->add('name');
    }

    protected function configureListFilter(ListMapper $listMapper)
    {
        $listMapper->addIdentifier('name');
    }
} 

Entity\Department.php

//...
public function __toString()
{
    $name = $this->getName();
    return empty($name) ? 'Add Department' : $name;
}

The thing is, I did not integrate SonataUserBundle with this project as I find it inappropriate to the spec. Any ideas why am I getting an empty list view? For some reason, the configureListFilter is not called.

  • 写回答

1条回答 默认 最新

  • dongtaogou6226 2014-08-30 14:31
    关注

    Shame on me! the issue is with the function name

    configureListFilter
    

    It should be

    configureListField
    

    waaah!.. took me long to realize that typo crap.. Thanks @AldeeMativo for the help

    评论

报告相同问题?

悬赏问题

  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题