这是我通过 api 添加记录的基本操作
public function createAction(Request $request){
$data = array();
$data['employeeCode'] = $request->request->get('employeeCode');
$data['employeeDescription'] = $request->request->get('employeeDescription');
$data['firstName'] = $request->request->get('firstName');
$data['lastName'] = $request->request->get('lastName');
$data['address'] = $request->request->get('address');
$data['suburb'] = $request->request->get('suburb');
$data['postcode'] = $request->request->get('postcode');
$data['country'] = $request->request->get('country');
$data['phone'] = $request->request->get('phone');
$data['mobile'] = $request->request->get('mobile');
$emp = new Employees();
$emp->setEmployeeCode($data['employeeCode']);
$emp->setEmployeeDescription($data['employeeDescription']);
$emp->setFirstName($data['firstName'] );
$emp->setLastName($data['lastName']);
$emp->setAddress($data['address']);
$emp->setSuburb($data['suburb']);
$emp->setCountry($data['country']);
$emp->setSuburb($data['phone']);
$emp->setCountry($data['mobile']);
$em = $this->get('doctrine')->getEntityManager();
$em->persist($emp);
$em->flush();
$view = View::create();
$view->setData($emp);
return $view;
这对我有用,但我想将它与我的员工表单绑定,这样我就可以从我的表单验证器获得每一个验证,而且我是 symfony2 的新手,所以我不知道该怎么做......