我将表单提交给与输出表单的控制器不同的控制器.
我的问题是你如何检查提交的数据是否有效?
我尝试过几件事.我要验证的主要内容是"_token"
我该怎么做呢?
这是我的代码示例.
/*
Out put the search form
*/
public function searchAction(Request $request)
{
$form = $this->createFormBuilder()
->setAction($this->generateUrl('email_search')) # <- route to the search process controler
->setMethod('GET')
->add('userSearch', 'text',array(
'required' => true,
'label' => false,
'attr' => array(
'placeholder' => 'Search User Email',
)
)
)
->add('Serch', 'submit')
->getForm();
return $this->render(
'TwigBundle:Search:Search.html.twig',
array(
'form' => $form->createView( )
)
);
}
/*
Process the search
*/
public function emailResultsAction(Request $request){
$form = $this->createFormBuilder()->getForm();
$form->handleRequest($request);
if ($form->isValid()) {
$ret …
Run Code Online (Sandbox Code Playgroud) 我有一个帖子的关系数据库。
帖子表 <-- OneToMany
帖子猫表 <-- ManyToOne
类别表 <-- OneToMany
如果我使用 Doctrine @ORM 来连接表,在使用注释的实体中。我出现白屏,并在错误日志中显示错误:
emergency.EMERGENCY: Allowed memory size of 1073741824 bytes exhausted (tried to allocate 1052508160 bytes) {"type":1,"file":"/[PATH TO SYMFONY]/vendor/twig/twig/lib/Twig/Extension/Debug.php","line":66}
Run Code Online (Sandbox Code Playgroud)
我已经多次提高内存限制,从 64M 到 1024M。
还有其他人发现这个问题吗?我认为执行> Gig 内存的文件是不好的。
如果我使用查询生成器编写查询,我会得到我期望的结果。我认为如果我能让 Doctrine 关系映射发挥作用,那就更好了。有人对此有意见吗?
我希望就此事得到一些建议。
提前致谢。
乔
------------ 编辑回复评论-------------------------------- ------
感谢您的评论@Cerad。数据库中只有大约 10 行。我也在app_dev.php 中。以下是我的文件的一些摘录。
帖子表
class Post
{
//... ^ table collumns
/**
* @ORM\OneToMany(targetEntity="PostCats", mappedBy="Post")
*/
protected $PostCats;
public function __construct()
{
$this->PostCats = new ArrayCollection();
}
}
Run Code Online (Sandbox Code Playgroud)
后猫加入表。
class PostCats
{
//... …
Run Code Online (Sandbox Code Playgroud)