我有自定义表单,它是各种实体的组合,使用以下代码对最终用户有意义:
$form = $this->container->get('form.factory')->createNamedBuilder(null, 'form')
->add('country', 'entity', array(
'class' => 'ACME\MyBundle\Entity\Country',
'query_builder' => function(EntityRepository $er) {
return $er->createQueryBuilder('c')->orderBy('c.en_name', 'ASC');
},
'label' => '* Country',
'required' => true
),
)
Run Code Online (Sandbox Code Playgroud)
即使在查阅http://symfony.com/doc/current/reference/forms/types/entity.html#reference-forms-entity-choices文档时,代码似乎也很好,但我一直收到以下错误:
The options "class", "query_builder" do not exist. Known options are: "action",
"attr", "auto_initialize", "block_name", "by_reference", "cascade_validation",
"choice_list", "choices", "compound", "constraints", "csrf_field_name",
"csrf_message", "csrf_protection", "csrf_provider", "csrf_token_id",
"csrf_token_manager", "data", "data_class", "disabled", "empty_data", "empty_value",
"error_bubbling", "error_mapping", "expanded", "extra_fields_message", "inherit_data",
"intention", "invalid_message", "invalid_message_parameters", "js_validation",
"label", "label_attr", "label_render", "mapped", "max_length", "method",
"multiple", "pattern", …Run Code Online (Sandbox Code Playgroud) 我有以下两个类具有ManyToMany关系并保存在一个名为的连接表中countries_involved.
class CountriesInvolved
{
/**
* @var integer
*/
private $id;
/**
* @var string
*/
private $description;
/**
* @var \DateTime
*/
private $createdAt;
/**
* @var \DateTime
*/
private $updatedAt;
/**
* @var \ACME\SouthBundle\Entity\Country
*/
private $country;
/**
* @var \Doctrine\Common\Collections\Collection
*/
private $involvement;
}
Run Code Online (Sandbox Code Playgroud)
和
class Involvement
{
/**
* @var integer
*/
private $id;
/**
* @var string
*/
private $name;
/**
* @var string
*/
private $description;
}
Run Code Online (Sandbox Code Playgroud)
该关系在YML中定义如下
manyToMany:
involvement: …Run Code Online (Sandbox Code Playgroud) 我已经发布了这3次,似乎看不到帖子不知道我做错了什么.
我创建了我的批处理操作,我的管理类如下:
namespace ACME\MyBundle\Admin;
use Sonata\AdminBundle\Admin\Admin;
use Sonata\AdminBundle\Show\ShowMapper;
use Sonata\AdminBundle\Datagrid\ListMapper;
use Sonata\AdminBundle\Datagrid\DatagridMapper;
use Sonata\AdminBundle\Validator\ErrorElement;
use Sonata\AdminBundle\Route\RouteCollection;
class JournalistProfileAdmin extends Admin
{
...........
...........
public function getBatchActions()
{
$lists = $this->getModelManager()->createQuery('ACME\MyBundle\Entity\ContactList', 'c')->execute();
$listsArray = array();
foreach ($lists as $list)
{
$listsArray[$list->getId()] = $list->getName();
}
$actions = parent::getBatchActions();
$actions['addToGroup'] = array(
'label' => $this->trans('action_add_to_group', array(), 'SonataAdminBundle'),
'ask_confirmation' => true,
'secondary' => $listsArray,
);
return $actions;
}
}
Run Code Online (Sandbox Code Playgroud)
然后扩展CRUDController,如下面的文件:
namespace ACME\MyBundle\Controller;
use Sonata\AdminBundle\Controller\CRUDController as Controller;
use Sonata\DoctrineORMAdminBundle\Datagrid\ProxyQuery as ProxyQueryInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
class JournalistProfileAdminController …Run Code Online (Sandbox Code Playgroud) 谁能明确地告诉我如何将我的symfony2应用程序连接到heroku上的ClearDB?
我输入了heroku上的连接字符串
$ heroku config
Run Code Online (Sandbox Code Playgroud)
但是当我把结果放在我的parameters.yml上时,我得到一个SQLSTATE [HY000] [2002]连接拒绝错误.
提前致谢
我试图在网上搜索这个问题的一个明确的解决方案,但那里的新手确实没有具体的解决方案.
我有一个条目有很多EntryListing.在我的EntryAdmin listMapper中,我可以轻松地按语句列出条目
->add('listings')
Run Code Online (Sandbox Code Playgroud)
它只返回EntryListing __toString()函数中定义的列表.
有没有办法通过覆盖getExportFields()函数导出数据时实现相同的方法,如下所示:
public function getExportFields()
{
return array('name','tel','email','deviceType','postedOn','createdAt','facilitator','listings');
}
Run Code Online (Sandbox Code Playgroud)
非常感谢您的帮助
I have a JObject item that looks like this:
{
"part":
{
"values": ["engine","body","door"]
"isDelivered": "true"
},
{
"manufacturer":
{
"values": ["Mercedes"]
"isDelivered": "false"
}
}
Run Code Online (Sandbox Code Playgroud)
How can I get the values as a single string in C#?
我在我的管理员中包含了一个相关模型,如下所示
->add('parameters', 'sonata_type_collection', array(
'type_options' => array(
// Prevents the "Delete" option from being displayed
'delete' => false,
)
), array(
'edit' => 'inline',
'inline' => 'table',
'sortable' => 'position',
))
Run Code Online (Sandbox Code Playgroud)
包含子管理员,我可以添加新行.但是,当我尝试添加第二个孩子时,我收到以下错误:
PropertyAccessor requires a graph of objects or arrays to operate on, but it found type "NULL" while trying to traverse path "parameters[0]" at property "0".
Run Code Online (Sandbox Code Playgroud)
我无法解释发生了什么,我正在使用symfony 2.7.3并使用Admin bundle的dev-master分支.我不知道这是否已被报道,我已经尝试检查问题列表但是没有看到它
我正在为仪表板创建一个自定义块,我想在其中显示持久存储在数据库中的信息.如何在块服务中获取容器或doctrine实体管理器的实例?
尝试谷歌搜索很多但到目前为止没有任何实质性的
我已经清除了我的symfony2应用程序,现在无法运行该应用程序,因为无法从命令行为实体生成代理,而默认情况下实际生成了一些代理.
我试过运行下面的命令,这通常在早期版本的symfony/doctrine中做了一些技巧:
php bin/console doctrine:ensure-production-settings --no-debug --env=prod
Run Code Online (Sandbox Code Playgroud)
但这一次我只收到以下回复:
Query Cache uses a non-persistent cache driver, Doctrine\Common\Cache\ArrayCache.
Run Code Online (Sandbox Code Playgroud)
有谁知道如何解决这个问题?
当我的时候,我的阵列看起来像这样 print_r(delegates[$i])
Array
(
['firstName'] => Brady
['surname'] => Manning
['jobTitle'] => CEO
['memberNumber'] => 123456
['dieteryRequirements'] => halal
)
Run Code Online (Sandbox Code Playgroud)
然后,当我尝试获取firstName时,echo delegates[$i]['firstName']我得到以下错误
Notice: Undefined index: firstName
Run Code Online (Sandbox Code Playgroud)
小学生的问题,但我真的很感激这里的一些帮助.
symfony ×8
sonata-admin ×4
doctrine-orm ×2
arrays ×1
c# ×1
heroku ×1
json.net ×1
one-to-many ×1
php ×1
sonata ×1