/** * Takes the request parameters and passes them through the form associated with this controller. * * @param Request $request * * @throws BadRequestHttpException if the request parameters could not be validated with the form. * * @return FormInterface */ protected function validateRequestParameters(Request $request) { $data = $request->request->all(); if (isset($data['id'])) { unset($data['id']); } // we explicitly do not load existing data; an edit is a PUT and should supply all valid data! $this->form->submit($data); if (!$this->form->isValid()) { throw new BadRequestHttpException($this->form->getErrorsAsString()); } return $this->form; }
/** * @param FormInterface $form * * @return array */ public function convertInvalid(FormInterface $form) { return array('errors' => $form->getErrorsAsString()); }
public function testValidData() { $this->form->submit($this->formData); $this->assertTrue($this->form->isValid()); $this->assertEquals('', $this->form->getErrorsAsString()); }