我目前正在尝试使用symfony表单来处理我的帖子并放入rest api端点.
目前我有:
$request = $this->getRequest(); $cc = new CreditCard(); $form = $this->createForm(new CreditCardType(), $cc); $form->handleRequest($request); if ($form->isValid()) { //... }
但是,表单永远不会有效.查看问题,似乎表单的isSubmitted字段为false,因此它永远不会通过验证.此外,由于这是一个api调用,我在creditcardtype中将csrf_protection设置为false.
以下是我向用户提交的数据的示例:
{ "credit_card": { "name" : "Example Name" ... } }
如何将此post/put请求注册为已提交并且表单验证者通过?谢谢.