小编Dim*_*dis的帖子

Symfony2 FOSRestBundle PUT Action FORM返回空结果

我正在使用Symfony 2.2和最新版本的FOSRestBundle.所以我设法让大多数动作都有效,但我似乎遇到了FormBuilder的问题,我正在通过PUT调用请求.

我检查了请求对象,它来自我的Backbone.je模型​​,因为它应该(.save())但是在绑定到表单后,实体返回只有id导致flush()抛出错误,因为必需的字段没有填补.

控制器中的操作:

header('Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS ');
header('Allow GET, POST, PUT, DELETE, OPTIONS ');
header('Access-Control-Allow-Credentials: true');
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Headers: Content-Type, *');

use FOS\RestBundle\Controller\FOSRestController;
use FOS\RestBundle\Controller\Annotations as Rest;
use FOS\RestBundle\Routing\ClassResourceInterface;
use FOS\Rest\Util\Codes;
use Symfony\Component\HttpFoundation\Request;
use Greenthumbed\ApiBundle\Entity\Container;
use Greenthumbed\ApiBundle\Form\ContainerType;

class ContainerController extends FOSRestController implements ClassResourceInterface
{
/**
 * Put action
 * @var Request $request
 * @var integer $id Id of the entity
 * @return View|array
 */
public function putAction(Request $request, $id)
{
    $entity = $this->getEntity($id);
    $form = $this->createForm(new …
Run Code Online (Sandbox Code Playgroud)

php symfony-forms symfony fosrestbundle

8
推荐指数
3
解决办法
9746
查看次数

持久化实体时如何创建事件监听器

我对 Symfony 上的事件监听器非常陌生,我想找到一种在特定实体(即用户)持久化时触发事件的好方法。

我已经搜索了文档,尽管我找到了对 onKernel 事件的引用,但我无法为我需要的内容创建侦听器。你能指出我正确的方向或给我一个例子吗?

symfony doctrine-orm

2
推荐指数
1
解决办法
8115
查看次数

PHP多行正则表达式

大家好,我正在尝试为PHP创建一个正则表达式,以使我能够获取报价和作者。如果一切都是一行,那么我就使它工作了,但是将其放到多行中的那一刻,它就停止了工作。我究竟做错了什么?

(\[quote\])(.*)(\|)(.*)(\[\/quote\])
Run Code Online (Sandbox Code Playgroud)

[quote]造船厂的沉默,街道上的沉默,哈根波特的船闸和码头将在您睡觉时抢劫您。|流行的儿童韵律

[quote]让您沉睡。|流行的儿童韵[/ quote]

php regex

1
推荐指数
1
解决办法
204
查看次数