我有简单的表格
$transformer = new ModuleToArrayTransformer($this->entityManager);
$builder->add('modules', 'collection', array(
'type' => 'checkbox',
'required' => false,
'data' => $options['data'][0]->getModules(),
))
->add('save', 'submit', array(
'label' => 'btn_update_and_edit_again',
'attr' => array(
'class' => 'btn btn-primary'
)
))
->addViewTransformer($transformer);
和它的控制器:
$em = $this->getDoctrine()->getManager();
$user = $this->get('security.context')->getToken()->getUser();
$module = $em->getRepository('AcmeProjectBundle:Module')
->findBy(
array(
'user' => $userId,
'project' => $projectId,
)
);
if (!$module) {
$module = $this->createAction($projectId, $userId);
}
$userData = $em->getRepository('AcmeSonataUserBundle:User')->find($userId);
$projectData = $em->getRepository('AcmeProjectBundle:Project')->find($projectId);
$form = $this->createForm(new ModuleType($em), $module, array('user' => $userData, 'project' => $projectData));
if ($request->getMethod() == 'GET') {
if ($form->isValid()) {
}
}
return $this->render('AcmeProjectBundle:Module:edit.html.twig',
array(
'form' => $form->createView(),
'projectId' => $projectId,
'userId' => $userId,
)
);
该表格与另一个表格相连。当我单击第一个表单中的复选框时,会正确生成此表单。直到我尝试$form->bind($request);
当我尝试绑定请求时,它会显示“此值不正确”之类的东西
似乎$_GET
很好
array (size=1) 'acme_projectbundle_module' => array (size=2) 'modules' => array (size=8) 'stats' => string '1' (length=1) 'time' => string '1' (length=1) 'issues' => string '1' (length=1) 'metrics' => string '1' (length=1) 'timeLine' => string '1' (length=1) 'information' => string '1' (length=1) 'status' => string '1' (length=1) 'risks' => string '1' (length=1) 'save' => string '' (length=0)
以及$request
变量
如果表单看起来与我$_GET
的请求完全一样,有什么问题?据我所知 $_GET 应该包含与$request->parameters
字段相同的值。那应该是什么样子呢?问题出在哪里?