public function addAction() { $client = new Client(); $form = new ClientForm(); $form->bind($client); $form->get('submit')->setValue('Add'); $request = $this->getRequest(); if ($request->isPost()) { $form->setInputFilter($client->getInputFilter()); $form->setData($request->getPost()); if ($form->isValid()) { $this->getClientTable()->saveClient($client); foreach ($client->getPhoneNumbers() as $phoneNumber) { $phoneNumber->setOwner($client->getId()); $this->getPhoneNumberTable()->savePhoneNumber($phoneNumber); } foreach ($client->getEmailAddresses() as $emailAddress) { $emailAddress->setOwner($client->getId()); $this->getEmailAddressTable()->saveEmailAddress($emailAddress); } foreach ($client->getPostAddresses() as $postAddress) { $postAddress->setOwner($client->getId()); $this->getPostAddressTable()->savePostAddress($postAddress); } // Redirect to list of clients return $this->redirect()->toRoute('mvitclient'); } } return array('form' => $form); }
public function addAction() { $client = new Client(); $form = new ClientForm(); $form->bind($client); $form->get('submit')->setValue('Add'); $request = $this->getRequest(); if ($request->isPost()) { $form->setInputFilter($client->getInputFilter()); $form->setData($request->getPost()); if ($form->isValid()) { $this->clientService->saveClient($client); // Redirect to list of clients return $this->redirect()->toRoute('mvitclient'); } } return array('form' => $form); }