Skip to content

Instantly share code, notes, and snippets.

@TomHAnderson
Created June 20, 2013 18:38
Show Gist options
  • Save TomHAnderson/5825379 to your computer and use it in GitHub Desktop.
Save TomHAnderson/5825379 to your computer and use it in GitHub Desktop.
Form submission without relations set in exchangeArray
$builder = new AnnotationBuilder();
$form = $builder->createForm($test);
...
$form->get('testResult')->setValueOptions(
$this->doctrineSelectOptions(
'DbLoadCd\Entity\TestResult',
[],
['name' => 'ASC'],
['Application\Service\Security', 'view']
)
);
if ($this->getRequest()->isPost()) {
$form->setData($this->getRequest()->getPost()->toArray());
$form->setUseInputFilterDefaults(false);
$form->setInputFilter($test->getInputFilter());
if ($form->isValid()) {
$test->setProject($project);
$test->setOwner($em->getRepository('AppleConnect\Entity\User')->find($form->getData()['owner']));
$test->setOperator($em->getRepository('AppleConnect\Entity\User')->find($form->getData()['operator']));
$test->setTestType($em->getRepository('DbLoadCd\Entity\TestType')->find($form->getData()['testType']));
$test->setTestStatus($em->getRepository('DbLoadCd\Entity\TestStatus')->find($form->getData()['testStatus']));
$test->setTestResult($em->getRepository('DbLoadCd\Entity\TestResult')->find($form->getData()['testResult']));
$test->exchangeArray($form->getData());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment