在Admin类的SonataAdminBundle中,我无法在ManyToMany字段上创建orderBy.
例如作者和书.作者可以有很多书,以及书可以有很多Autors.在上面的链接中写道,我可以使用表单字段的查询.所以我可以准备一个查询,选择作者并按名称加工.如何管理?如何在那里获取EntityManager以创建查询并通过查询选项传递它?
protected function configureFormFields(FormMapper $formMapper)
{
$formMapper
->add('name','text')
->add('author', 'sonata_type_model', array('query' => ....), array('edit' => 'inline'))
;
}
Run Code Online (Sandbox Code Playgroud) 我收到此异常,这是已知问题之一,并建议我php5-intl通过 apt-get安装并重新启动我的Nginx服务器。
似乎什么都解决不了。
在渲染模板期间抛出异常
(“Symfony\Component\Locale\Stub\StubIntlDateFormatter::__construct() 方法的参数 $locale value 'en_IN' 行为未实现。仅支持 'en' 语言环境。请
在 SonataAdminBundle:CRUD:base_list_field.html.twig 第 4 行安装‘intl’扩展以获得完整的本地化功能。”) 。
我一直在努力让SonataMedia与Symfony 2.0.16一起工作......但没有成功.谷歌搜索似乎没有多少人使用该捆绑或有一个我不知道的教程或操作方法,因为我没有得到很多关于我到目前为止的错误消息的信息.
无论如何,我的最后一次尝试给出了下一条错误消息:
The current field `path` is not linked to an admin. Please create one for the target entity : ``
Run Code Online (Sandbox Code Playgroud)
"path"是用于保存文件图像(相对)路径的字段.
AttachmentAdmin.php
<?php
class AttachmentAdmin extends Admin
{
protected function configureFormFields(FormMapper $formMapper)
{
$formMapper
->add(
'path',
'sonata_type_collection',
array(
'required' => true
),
array(
'edit' => 'inline',
'inline' => 'table',
'sortable' => 'position',
'targetEntity' => 'Application\Sonata\MediaBundle\Entity\GalleryHasMedia',
'link_parameters' => array(
'context' => 'attachment'
)
)
)
->add('notes', 'textarea', array('required' => false))
;
}
// other methods
}
Run Code Online (Sandbox Code Playgroud)
Attachment.php
<?php
class …Run Code Online (Sandbox Code Playgroud) 我有这样的领域
/**
* @ORM\ManyToOne(targetEntity="Town")
**/
protected $town;
Run Code Online (Sandbox Code Playgroud)
和Admin类有这样的方法
protected function configureDatagridFilters(DatagridMapper $datagridMapper)
{
$datagridMapper
...
->add('town', null, array('label' => 'Town'), null, array('expanded' => true, 'multiple' => true))
;
}
Run Code Online (Sandbox Code Playgroud)
它给了我这样的过滤器:
我的问题是:我可以为Town实体检索设置自定义sql\dql 吗?例如,只选择ID为IN(1,2)的城镇?
假设我有两个实体:
1.产品
/**
* @ORM\Table()
* @ORM\Entity
*/
class Product
{
/*
* @ORM\Column(name="name", type="string", length=255)
*/
private $name;
/**
* @ORM\OneToMany(targetEntity="Catalog", mappedBy="product")
*/
public $catalogs;
public function __construct()
{
$this->catalogs = new \Doctrine\Common\Collections\ArrayCollection();
}
}
Run Code Online (Sandbox Code Playgroud)
2.Catalog
/**
*
* @ORM\Table()
* @ORM\Entity
*/
class Catalog
{
/**
* @ORM\ManyToOne(targetEntity="Product", inversedBy="catalogs")
*/
private $product;
/**
* @ORM\Column(name="name", type="string", length=255)
*/
private $name;
}
Run Code Online (Sandbox Code Playgroud)
我的ProductAdmin:
class ProductAdmin extends Admin
{
protected function configureFormFields(FormMapper $formMapper)
{
$formMapper
->add('name')
->add('catalogs', 'sonata_type_model') …Run Code Online (Sandbox Code Playgroud) 我真的很紧张,因为缺少足够的资源来安装SonataDoctrineMongoDBAdminBundle以及它的依赖项如sonataUserBundle.我一直试图安装这个捆绑包15天.我做了各种各样的agaian,并再次在奏鸣曲的官方页面中讲述了什么.但它不能正常工作.在将sonataUserBundle扩展为ApplicationUserBundle之后,我的最终文档是:
user.php的
<?php
/**
* This file is part of the <name> project.
*
* (c) <yourname> <youremail>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Application\Sonata\UserBundle\Document;
use Sonata\UserBundle\Document\BaseUser as BaseUser;
/**
* This file has been generated by the EasyExtends bundle ( http://sonata-project.org/bundles/easy-extends )
*
* References :
* working with object : http://www.doctrine-project.org/docs/mongodb_odm/1.0/en/reference/working-with-objects.html
*
* @author <yourname> <youremail>
*/
class User extends …Run Code Online (Sandbox Code Playgroud) symfony fosuserbundle symfony-sonata sonata-admin sonata-user-bundle
我在我的Symfony 2应用程序上安装了几个Sonata软件包(用户,管理员等),但在使用它们一段时间后,我觉得我不喜欢它们并想要删除它们.
我已经更新了我的composer.json和AppKernel.php文件,删除了与Sonata有关的任何内容.我还删除了所有相关的路由,配置和安全文件条目.但是,我现在无法更新我的数据库架构.
每当我运行一个时,我会收到以下错误:
[Doctrine\DBAL\DBALException]
Unknown column type "json" requested. Any Doctrine type that you use has to
be registered with \Doctrine\DBAL\Types\Type::addType(). You can get a lis
t of all the known types with \Doctrine\DBAL\Types\Type::getTypeMap(). If t
his error occurs during database introspection then you might have forgot t
o register all database types for a Doctrine Type. Use AbstractPlatform#reg
isterDoctrineTypeMapping() or have your custom types implement Type#getMapp
edDatabaseTypes(). If the type name is empty you might have a problem …Run Code Online (Sandbox Code Playgroud) ..我用Systfony 2.3.5使用FOSUSer Bundel和PUGXMultiUser Bundle进行这个项目是怎么回事,我想使用SonataAdmin Bundle但是在配置之后就出现了关于Menu的这个问题,我无法在Dashboard中看到..这里配置你认为我错过了什么!!
config.yml
imports:
- { resource: parameters.yml }
- { resource: security.yml }
- { resource: @PokTVBundle/Resources/config/admin.yml }
framework:
#esi: ~
translator: { fallback: %locale% }
secret: %secret%
router:
resource: "%kernel.root_dir%/config/routing.yml"
strict_requirements: ~
form: ~
csrf_protection: ~
validation: { enable_annotations: true }
templating:
engines: ['twig']
#assets_version: SomeVersionScheme
default_locale: "%locale%"
trusted_proxies: ~
session: ~
fragments: ~
http_method_override: true
# Twig Configuration
twig:
debug: %kernel.debug%
strict_variables: %kernel.debug%
# Assetic Configuration
assetic:
debug: %kernel.debug%
use_controller: false
bundles: [ ] …Run Code Online (Sandbox Code Playgroud) 我尝试用 Symfony 制作一个网站。所以我安装了 SonataAdminBundle 和 SonataMediaBundle。
我有一个关于奏鸣曲媒体的问题。我创建了一个包含大量图像媒体的画廊,但我不知道如何从我的控制器访问它。
如何让我的媒体(图像)包含在我的画廊中以在我的模板中显示它们?
谢谢你的帮助!
编辑:我解决了我的问题!
所以在我的模板中,我这样做:
{% for img in MyEntity.gallery.galleryHasMedias %}
<img src={% path img.media, 'reference'%}>
{% endfor %}
Run Code Online (Sandbox Code Playgroud) 我正在尝试将一个管理员设置为 Sonata Admin Bundle 中其他管理员的孩子。
我有 2 个管理课程:
CategoryAdmin
此类包含以下方法
protected function configureSideMenu(MenuItemInterface $menu, $action, AdminInterface $childAdmin = null)
{
$id = $this->getRequest()->get('id');
$menu->addChild(
$this->trans('Projects'),
array('uri' => $this->getChild('sonata.admin.project')->generateUrl('list', array('id' => $id)))
);
}
Run Code Online (Sandbox Code Playgroud)ProjectAdmin
此类包含protected $parentAssociationMapping = 'category';
category表示多对一关联的模型类中的属性。
我在 CategoryAdmin 的服务配置中添加了以下几行
calls:
- [ addChild, ["@sonata.admin.project"]]
Run Code Online (Sandbox Code Playgroud)
使用此配置不会生成子管理员的路由。SideMenu(顶部菜单)中的链接指向/admin/project/list?childId=1&id=1
这是CategoryAdminwith的孩子的输出dump()
array:1 [?
"sonata.admin.project" => ProjectAdmin {#406 ?}
]
Run Code Online (Sandbox Code Playgroud)
这意味着我的孩子管理员的配置似乎是正确的。我不知道为什么没有生成子管理员的路由。
我希望有人能给我一个提示,可能是什么问题。
symfony ×10
symfony-sonata ×10
sonata-admin ×6
php ×3
doctrine ×1
sonata ×1
symfony-2.1 ×1
translation ×1