当表单被提交时,刷新后再次显示,请求被绑定以形成并显示选定的值。如果表单之前没有提交,我想用外部数组的数据(表格中的数据)来保存表单。表单是数组类型,没有连接到任何实体,因为它用作db过滤器。Symfony2:为扩展选择域设置“设置”值(复选框)
我有选择表单域扩大,多个(复选框),如下配置:
$categoryForm = array();
$form = $this->createFormBuilder($categoryForm)
->add('id', 'choice', array('choices' => $arrayOfChoices,
'multiple' => true,
'expanded' => true))
->getForm();
if ($request->getMethod() == 'POST') {
$form->bindRequest($request);
}
你能更精确吗?在哪里传递?到$ categoryForm?或用setData()方法?那么如果数据是选择数组,那么setData()如何呢? – nysander 2012-04-02 10:22:03