public function create($data) { $form = new SubscriberForm(); $album = new Subscriber(); $form->setInputFilter($album->getInputFilter()); $form->setData($data); if ($form->isValid()) { $subscriber->exchangeArray($form->getData()); $id = $this->getSubscriberTable()->saveSubscriber($subscriber); } return $this->get($id); }
public function addAction() { $product_id = (int) $this->params()->fromRoute('id', 0); if (!$product_id) { //return $this->redirect()->toRoute('product'); } $form = new SubscriberForm(); $form->get('submit')->setValue('Add'); $request = $this->getRequest(); if ($request->isPost()) { $subscriber = new Subscriber(); $form->setInputFilter($subscriber->getInputFilter()); $form->setData($request->getPost()); if ($form->isValid()) { print_r($form->getData()); $subscriber->exchangeArray($form->getData()); $this->getSubscriberTable()->saveSubscriber($subscriber); // Redirect to list of subscribers return $this->redirect()->toRoute('subscriber'); } } return array('product_id' => $product_id, 'form' => $form); }