protected function getForm($name = 'name', $propertyPath = null, $dataClass = null, $errorMapping = array(), $virtual = false, $synchronized = true) { $config = new FormConfigBuilder($name, $dataClass, $this->dispatcher, array('error_mapping' => $errorMapping)); $config->setMapped(true); $config->setVirtual($virtual); $config->setPropertyPath($propertyPath); $config->setCompound(true); $config->setDataMapper($this->getDataMapper()); if (!$synchronized) { $config->addViewTransformer(new CallbackTransformer(function ($normData) { return $normData; }, function () { throw new TransformationFailedException(); })); } return new Form($config); }
/** * @expectedException \Symfony\Component\Form\Exception\LogicException */ public function testViewDataMustBeObjectIfDataClassIsSet() { $config = new FormConfigBuilder('name', 'stdClass', $this->dispatcher); $config->addViewTransformer(new FixedDataTransformer(array('' => '', 'foo' => array('bar' => 'baz')))); $form = new Form($config); $form->setData('foo'); }