/** * Creates new form */ public function createFormAction() { $params = $this->Request()->getParams(); $formModel = new Form(); $params['attribute'] = $params['attribute'][0]; $params['shopIds'] = $params['shopIds'] ? '|' . implode('|', $params['shopIds']) . '|' : null; $formModel->fromArray($params); $this->getManager()->persist($formModel); $this->getManager()->flush(); $data = $this->getManager()->toArray($formModel); $data['shopIds'] = $this->explodeShopIds($data['shopIds']); $this->View()->assign(array('success' => true, 'data' => $data)); }
/** * Test case */ public function testFormShouldBePersisted() { $form = new Form(); $form->fromArray($this->testData); $this->em->persist($form); $this->em->flush(); $formId = $form->getId(); // remove form from entity manager $this->em->detach($form); unset($form); $form = $this->repo->find($formId); foreach ($this->testData as $fieldname => $value) { $getMethod = 'get' . ucfirst($fieldname); $this->assertEquals($form->{$getMethod}(), $value); } }
/** * Creates new form */ public function createFormAction() { $params = $this->Request()->getParams(); $formModel = new Form(); $params['attribute'] = $params['attribute'][0]; $formModel->fromArray($params); $this->getManager()->persist($formModel); $this->getManager()->flush(); $data = $this->getManager()->toArray($formModel); $this->View()->assign(array('success' => true, 'data' => $data)); }