I have a problem using my url view helper. I have defined custom routes like so:
; Index
routes.domain.type = 'Zend_Controller_Router_Route_Static'
routes.domain.route = '/'
routes.domain.defaults.controller = index
routes.domain.defaults.action = index
Run Code Online (Sandbox Code Playgroud)
使用自定义网址时,一切正常,但我无法正常组合.我尝试使用视图中的以下代码添加链接:
$this->url(array('controller' => 'search', 'action' => 'index');
Run Code Online (Sandbox Code Playgroud)
问题是,当我在索引控制器的索引页面中使用此代码时,返回的url是当前控制器/操作的url,而不是我需要的url.
简而言之:
当我在OneToMany关系中使用'sonata_type_collection'时,我必须指定关系的另一面,在"创建操作"中仍然不存在,并且可以设置"更新操作",但也可以完全指定不同的父母.
更详细的解释:
我正在使用Sonata Admin Bundle进行CRUD操作,并且假设我只有Post(id,title,content)和Tag(id,post_id,title)实体.我希望能够在编辑Post实体时添加和删除标记实体,因此我使用'sonata_type_collection'字段.
这是PostAdmin类的configureFormFields方法:
protected function configureFormFields(FormMapper $formMapper)
{
$formMapper
->add('title')
->add('content')
->add('tags', 'sonata_type_collection', array(), array(
'edit' => 'inline',
'inline' => 'table'
))
))
;
}
Run Code Online (Sandbox Code Playgroud)
问题是在创建表单中,当我添加新标签时,我必须指定帖子和标题,但邮件仍然不存在,所以我无法添加标签.当我正在编辑帖子时,我可以添加新标签,但是对于其中的每一个,我都必须明确设置帖子,并且我能够为完全不同的帖子添加标签.
你能告诉我如何解决这个问题吗?