【发布时间】:2011-09-26 20:58:13
【问题描述】:
我有这样的控制器操作:
public function createAction()
{
$entity = new Client();
$request = $this->getRequest();
$form = $this->createForm(new ClientType(), $entity);
$form->bindRequest($request);
if ($form->isValid()) {
$em = $this->getDoctrine()->getEntityManager();
$em->persist($entity);
$em->flush();
return $this->redirect($this->generateUrl('client_show', array('id' => $entity->getId())));
}
return array(
'entity' => $entity,
'form' => $form->createView()
);
}
底层Client 实体有一个字段type 现在可以取值[0, 1],我已经为Client 实体定义了两个验证组:person 和company。
如何根据用户在type 字段中输入的值更改/选择验证组?
【问题讨论】: