我有这个简单的Type Class
class XXXXType extends AbstractType
{
/**
* Build form method
*
* @param FormBuilderInterface $builder Builder interface
* @param array $options Options
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('XXX', 'integer');
}
/**
* Set default options to the type
*
* @param OptionsResolverInterface $resolver
*/
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$resolver->setDefaults(array(
'csrf_protection' => false
));
}
/**
* Get type name
*
* @return string
*/
public function getName()
{
return '';
}
}
和我的控制器
/**
* Create a new XXXX
*
* @param Request $request Action Request
*
* @Route("/XXXX")
* @Method({"POST"})
*
* @ApiDoc(
* resource=true,
* description="XXXXX",
* input="XXXType"
* )
*/
public function setXXXXXXAction(Request $request)
{
$form = $this->createForm(new XXXType());
$response = new JsonResponse();
$form->submit($request);
if ($form->isValid()) {
return $response->setStatusCode(201);
}
return $response
->setData(array('Message' => $form->getErrorsAsString(0)))
->setStatusCode(500);
}
我总是从表单中收到同样的错误:
“错误:上传的文件太大。请尝试上传较小的文件。\ XXX:\ n没有错误\ n