我有一个班级表格:
class MyForm extends AbstractType
{
public function buildForm(FormBuilder $builder, array $options = array())
{
$builder->add('types', 'choice', array(
'choices' => $options['data']['types'],
'required' => false,
'multiple' => true,
'expanded' => true,
));
$builder->add('dateFrom', 'date', array(
'years' => range(date('Y') - 5, date('Y')),
'required' => false,
));
}
}
在我的控制器中我会做下一步:
$form = $this->createForm(new TransSearchForm, array(
'types' => $myCheckboxArray
));
// getting form data from required
$data = $this->getRequest()->get($form->getName());
/*... some changes dateFrom param in $data array ...*/
$form->setData($data);
并选中未选中的复选框( 但是,如果我使用
$form->bindRequest($this->getRequest());
所有工作正确 - 检查了检查的checboxes。但是我的dateFrom param没有改变......
所以,我需要: 1)手动更改dateFrom param 2)查看发送表单后检查的复选框
使用bindRequest或setData - 无论如何。有人可以帮帮我吗?