symfony4 - Sonata admin sortabe 列表,字段为空白
问题描述
我试图在我的奏鸣曲管理包中的一张表上制作一个简单的可排序系统,我已按照本教程进行操作(https://symfony.com/doc/master/bundles/SonataAdminBundle/cookbook/recipe_sortable_listing.html#the-recipe ) 但我没有能力做到这一点。
我已经仔细地执行了每个步骤,但是在我的管理表上我只能看到一个空白的操作字段,其中没有箭头。
我已经搜索并搜索了文章,但没有任何成功,我觉得我非常接近弄清楚。
这是我的 src/Entity/Podcast.php 文件
/**
* @Gedmo\SortablePosition
*@ORM\Column(name="position", type="integer")
*/
private $position;
//getters and setters
public function setPosition($position)
{
$this->position = $position;
return $this;
}
public function getPosition()
{
return $this->position;
}
据我所知,我的实体文件很好
我的 services.yaml 文件
//Gedmo
gedmo.listener.sortable:
class: Gedmo\Sortable\SortableListener
tags:
- { name: doctrine.event_subscriber, connection: default }
calls:
- [ setAnnotationReader, [ "@annotation_reader" ] ]
//podcast admin
admin.podcast:
class: App\Admin\PodcastAdmin
tags:
- name: sonata.admin
manager_type: orm
label: 'Programa'
show_mosaic_button: true
arguments:
- ~
- App\Entity\Podcast
- 'PixSortableBehaviorBundle:SortableAdmin'
calls:
- [ setPositionService, ['@pix_sortable_behavior.position']]
我的 stof_doctrine_extension.yaml 文件
stof_doctrine_extensions:
default_locale: en_US
orm:
default:
sortable: true
最后但并非最不重要的是,我的 PodcastAdmin.php 文件
protected function configureRoutes(RouteCollection $collection)
{
$collection->add('move', $this->getRouterIdParameter().'/move/{position}');
}
protected function configureListFields(ListMapper $listMapper) {
$listMapper
->add('id')
->addIdentifier('title')
->add('description')
->add('author.name')
->add('_action', null, [
'actions' => [
'move' => [
'template' => '@App/Admin/_sort.html.twig',
],
],
]);
}
因为现在我收到以下错误在第 17 行的@SonataAdmin/CRUD/list__action.html.twig 中没有命名空间“App”的注册路径。
如果我将模板值切换为@PixSortableBehavior/Default/_sort.html.twig,我可以看到页面但操作字段全为空白,没有箭头
解决方案
您可以在 twig.yml 或任何类似的配置文件中注册 App 命名空间,它对我有帮助但不是最佳的。
应用程序/配置/config.yml
枝条: # ... 路径: “%kernel.root_dir%/path/to/templates”:应用
推荐阅读
- javascript - 更新 Redux 的 store 后,React.js 什么时候重新渲染组件?
- angular - BehaviourSubject 只发出一次值
- c# - C# MongoDB 和投影。因序列化异常而失败
- firebase - 无法在 Firebase 云功能助手中获得用户响应
- python - 使用python在文件中搜索这些字符串后如何打印?
- stata - 在 estout 命令生成的文件中添加 TeX 代码
- hibernate - Hibernate 查询缓存 LazyInitializationException
- c++ - 为什么三元操作失败不会在try catch中咳嗽
- java - 向Firebase写入数据只能在刚登录后才能工作,除非退出并重新登录才能成功
- python - 无法运行Qt设计器编译的python代码