Example #1
0
 public function testLabelIdIsCorrect()
 {
     $form = new \Zend\Form\Form();
     $form->setElementsBelongTo('comment');
     $this->element->setLabel("My Captcha");
     $form->addElement($this->element);
     $html = $form->render($this->getView());
     $expect = sprintf('for="comment-%s-input"', $this->element->getName());
     $this->assertRegexp("/<label [^>]*?{$expect}/", $html, $html);
 }
 public function productDetailAction()
 {
     $productId = $this->params()->fromRoute('id');
     $productTable = $this->getServiceLocator()->get('StoreProductsTable');
     $product = $productTable->getProduct($productId);
     //Prepare AddToCart Form
     $form = new \Zend\Form\Form();
     $form->add(array('name' => 'qty', 'attributes' => array('type' => 'text', 'id' => 'qty', 'required' => 'required'), 'options' => array('label' => 'Quantity')));
     $form->add(array('name' => 'submit', 'attributes' => array('type' => 'submit', 'value' => 'Purchase')));
     $form->add(array('name' => 'store_product_id', 'attributes' => array('type' => 'hidden', 'value' => $product->id)));
     $viewModel = new ViewModel(array('product' => $product, 'form' => $form));
     return $viewModel;
 }
 public function indexAction()
 {
     $this->layout('layout/myaccount');
     $this->layout()->setVariable('mail_active', 'active');
     $userTable = $this->getServiceLocator()->get('UserTable');
     $allUsers = $userTable->fetchAll();
     $usersList = array();
     foreach ($allUsers as $user) {
         $usersList[$user->id] = $user->name . '(' . $user->email . ')';
     }
     $user = $this->getLoggedInUser();
     $request = $this->getRequest();
     if ($request->isPost()) {
         $msgSubj = $request->getPost()->get('messageSubject');
         $msgText = $request->getPost()->get('message');
         $toUser = $request->getPost()->get('toUserId');
         $fromUser = $user->id;
         $this->sendOfflineMessage($msgSubj, $msgText, $fromUser, $toUser);
         // to prevent duplicate entries on refresh
         return $this->redirect()->toRoute('users/mail', array('action' => 'sendOfflineMessage'));
     }
     //Prepare Send Message Form
     $form = new \Zend\Form\Form();
     $form->setAttribute('method', 'post');
     $form->setAttribute('enctype', 'multipart/form-data');
     $form->add(array('name' => 'toUserId', 'type' => 'Zend\\Form\\Element\\Select', 'attributes' => array('type' => 'select'), 'options' => array('label' => 'To User')));
     $form->add(array('name' => 'messageSubject', 'attributes' => array('type' => 'text', 'id' => 'messageSubject', 'required' => 'required'), 'options' => array('label' => 'Subject')));
     $form->add(array('name' => 'message', 'attributes' => array('type' => 'textarea', 'id' => 'message', 'required' => 'required'), 'options' => array('label' => 'Message')));
     $form->add(array('name' => 'submit', 'attributes' => array('type' => 'submit', 'value' => 'Send'), 'options' => array('label' => 'Send')));
     $form->get('toUserId')->setValueOptions($usersList);
     $viewModel = new ViewModel(array('form' => $form, 'userName' => $user->name));
     return $viewModel;
 }
 public function indexAction()
 {
     $checkoutService = $this->getServiceLocator()->get('SpeckCheckout\\Service\\Checkout');
     $options = $checkoutService->getOptions();
     $paymentMethods = $options->getPaymentMethods();
     $paymentMethod = $checkoutService->getCheckoutStrategy()->getPaymentMethod();
     $methodString = $paymentMethod ? $paymentMethod->getPaymentMethod() : null;
     $methodForm = new \Zend\Form\Form();
     foreach ($paymentMethods as $i) {
         $valueOptions[$i->getPaymentMethod()] = array('value' => $i->getPaymentMethod(), 'label' => $i->getDisplayName(), 'selected' => $i->getPaymentMethod() === $methodString);
     }
     $methodForm->add(array('name' => 'method', 'type' => 'Zend\\Form\\Element\\Radio', 'options' => array('label' => 'Payment Method', 'value_options' => $valueOptions)));
     return array('form' => $methodForm);
 }
Example #5
0
 public function unserialiseAction()
 {
     $form = new \Zend\Form\Form();
     $form->setAttribute('method', 'post');
     $form->add(array('name' => 'code', 'attributes' => array('type' => 'textarea', 'class' => 'input-lg', 'style' => 'width:900px;height:300px;')));
     $form->bind(new \ArrayObject($this->params()->fromPost()));
     $viewModel = new ViewModel();
     $viewModel->setVariable('form', $form);
     $code = $this->params()->fromPost('code');
     if ($code) {
         $viewModel->setVariable("result", \DevelopmentLib\ArrayExporter::exportPhp54(unserialize($code)));
     }
     return $viewModel;
 }
 public function indexAction()
 {
     $request = $this->getRequest();
     if ($request->isPost()) {
         $queryText = $request->getPost()->get('query');
         $searchIndexLocation = $this->getIndexLocation();
         $index = Lucene\Lucene::open($searchIndexLocation);
         $this->searchResults = $index->find($queryText);
     }
     // prepare search form
     $form = new \Zend\Form\Form();
     $form->add(array('name' => 'query', 'attributes' => array('type' => 'text', 'id' => 'queryText', 'required' => 'required'), 'options' => array('label' => 'Search String')));
     $form->add(array('name' => 'submit', 'attributes' => array('type' => 'submit', 'value' => 'Search', 'style' => "margin-bottom: 8px; height: 27px;")));
     $viewModel = new ViewModel(array('form' => $form, 'searchResults' => $this->searchResults));
     return $viewModel;
 }
 public function indexAction()
 {
     $this->getLoggedInUser();
     $request = $this->getRequest();
     if ($request->isPost()) {
         $messageText = $request->getPost()->get('message');
         $fromUserId = $this->user->id;
         $this->sendMessage($messageText, $fromUserId);
         //to prevent duplicate entries on refresh
         return $this->redirect()->toRoute('group-chat');
     }
     $form = new \Zend\Form\Form();
     $form->add(array('name' => 'message', 'attributes' => array('type' => 'text', 'id' => 'messageText', 'required' => 'required'), 'options' => array('label' => 'Message')));
     $form->add(array('name' => 'submit', 'attributes' => array('type' => 'submit', 'value' => 'Send')));
     $form->add(array('name' => 'refresh', 'attributes' => array('type' => 'button', 'id' => 'btnRefresh', 'value' => 'Refresh')));
     return new ViewModel(array('form' => $form, 'userName' => $this->user->name));
 }
 public function indexAction()
 {
     $request = $this->getRequest();
     if ($request->isPost()) {
         $queryText = $request->getPost()->get('query');
         $searchIndexLocation = $this->getIndexLocation();
         $index = Lucene\Lucene::open($searchIndexLocation);
         $searchResults = $index->find($queryText);
         //            foreach ($searchResults as $searchResult) {
         //                \Zend\Debug\Debug::dump($searchResult->upload_id);
         //            }
     }
     // Подготовка формы поиска
     $form = new \Zend\Form\Form();
     $form->add(array('name' => 'query', 'attributes' => array('type' => 'text', 'id' => 'queryText', 'required' => 'required'), 'options' => array('label' => 'Search String')));
     $form->add(array('name' => 'submit', 'attributes' => array('type' => 'submit', 'value' => 'Search')));
     if ($request->isPost()) {
         $form->get('query')->setValue($request->getPost()->get('query'));
     }
     $viewModel = new ViewModel(array('form' => $form, 'searchResults' => $searchResults));
     return $viewModel;
 }
 /**
  * Method to process a simple form
  * User by createStatus()
  *
  * @param Zend\Form\Form $form 
  * @param string $user 
  * @param array $data 
  * @return mixed
  */
 protected function processSimpleForm($form, $user, array $data)
 {
     $form->setData($data);
     if ($form->isValid()) {
         $data = $form->getData();
         $data['user_id'] = $user->getId();
         unset($data['submit']);
         unset($data['csrf']);
         $response = ApiClient::postWallContent($user->getUsername(), $data);
         return $response['result'];
     }
     return $form;
 }
 public function contactusAction()
 {
     $request = $this->getRequest();
     if ($request->isPost()) {
         $messageText = $request->getPost()->get('message');
         $send_to = $request->getPost()->get('send_to');
         //var_dump($send_to);var_dump($messageText);exit;
         //$fromUserId = $user->users_id;
         $success = $this->sendOfflineMessage('subject', $messageText, 11, $send_to);
         if ($success) {
             // to prevent duplicate entries on refresh
             return $this->redirect()->toRoute('groupy', array('controller' => 'groupchat', 'action' => 'index', 'default', true));
         }
         echo 'ne prateno';
     }
     //Prepare Send Email Form
     $email_form = new \Zend\Form\Form();
     $email_form->add(array('name' => 'send_to', 'attributes' => array('type' => 'text', 'id' => 'send_to', 'required' => 'required'), 'options' => array('label' => 'Send to:')));
     $email_form->add(array('name' => 'message', 'attributes' => array('type' => 'text', 'id' => 'messageText', 'required' => 'required'), 'options' => array('label' => 'Message')));
     $email_form->add(array('name' => 'submit', 'attributes' => array('type' => 'submit', 'value' => 'Send')));
     $viewModel = new ViewModel(array('form' => $email_form));
     // var_dump(123);exit;
     return $viewModel;
 }
 /**
  * Create form to update Contact System Fields
  * @return \Zend\Form\Form
  */
 public function getContactSystemFieldsForm()
 {
     //create form
     $form = new \Zend\Form\Form();
     $form->setAttribute("id", 'system-fields-form');
     $form->add(array("name" => "source_dropdown", "type" => "select", "attributes" => array("id" => "source_dropdown", "title" => "Set from existing Sources"), "options" => array("label" => "Select Source", "value_options" => array("test"))));
     $form->add(array("name" => "source", "type" => "text", "attributes" => array("id" => "source"), "options" => array("label" => "Source")));
     $form->add(array("name" => "reference_dropdown", "type" => "select", "attributes" => array("id" => "reference_dropdown", "title" => "Set from existing References"), "options" => array("label" => "Select Reference", "value_options" => array("test"))));
     $form->add(array("name" => "reference", "type" => "text", "attributes" => array("id" => "reference"), "options" => array("label" => "Reference")));
     $form->add(array("name" => "user_id", "type" => "select", "attributes" => array("id" => "user_id", "required" => "required"), "options" => array("label" => "User", "value_options" => array())));
     $form->add(array("type" => "submit", "name" => "submit", "attributes" => array("value" => "Submit")));
     /**
      * Populate Dropdowns
      */
     //users
     $objUsers = $this->getFrontUsersModel()->fetchUsers();
     $arr_users = array();
     foreach ($objUsers as $objUser) {
         if (!is_numeric($objUser->id)) {
             continue;
         }
         //end if
         $arr_users[$objUser->id] = $objUser->uname;
     }
     //end foreach
     $form->get("user_id")->setValueOptions($arr_users);
     //sources
     $objSources = $this->getFrontContactsSystemFieldsModel()->fetchDistinctContactSources();
     $arr_sources = array();
     foreach ($objSources as $objSource) {
         $arr_sources[$objSource->source] = $objSource->source;
     }
     //end foreach
     $form->get("source_dropdown")->setValueOptions($arr_sources);
     //references
     $objReferences = $this->getFrontContactsSystemFieldsModel()->fetchDistinctContactReferences();
     $arr_references = array();
     foreach ($objReferences as $objRefence) {
         $arr_references[$objRefence->reference] = $objRefence->reference;
     }
     //end foreach
     $form->get("reference_dropdown")->setValueOptions($arr_references);
     return $form;
 }
 public function testBindingWorksAsExpected()
 {
     $form = new \Zend\Form\Form();
     $form->setHydrator(new \Zend\Stdlib\Hydrator\ClassMethods());
     $fieldset = new MoneyFieldset();
     $fieldset->init();
     $form->add($fieldset, array('name' => 'money'));
     $model = new TestModel();
     $form->bind($model);
     $this->assertEquals(5432.1, $fieldset->get('amount')->getValue());
     $this->assertEquals('ZAR', $fieldset->get('currency')->getValue());
     $form->setData(array('money' => array('amount' => 1234.56, 'currency' => 'GBP')));
     $this->assertTrue($form->isValid());
     $bound = $form->getData();
     $this->assertInstanceOf('NetglueMoney\\Form\\TestModel', $bound);
     $this->assertInstanceOf('NetglueMoney\\Money\\Money', $bound->money);
     $this->assertSame(123456, $bound->money->getAmount());
     $this->assertSame('GBP', $bound->money->getCurrencyCode());
 }
 public function getjurisdictionproductformAction()
 {
     //$response = new \Zend\Http\Response();
     //$response->getHeaders()->addHeaderLine('Content-Type', 'text/xml; charset=utf-8');
     //$response->setContent($xml);
     $marketid = (int) $this->params()->fromQuery('marketid', 0);
     $marketproductId = (int) $this->params()->fromQuery('marketproductId', 0);
     $form = new \Zend\Form\Form();
     $marketJurisdictions = $this->getEntityManager()->getRepository('GDI\\Entity\\RMarketJurisdiction')->findByMarket($marketid);
     foreach ($marketJurisdictions as $key => $marketJurisdiction) {
         $jurisAbbr = $marketJurisdiction->getJurisdiction()->getJurisdictionAbbr();
         //$form->setHydrator(new DoctrineHydrator($this->getEntityManager(), 'GDI\Entity\TJurisdictionProduct'));
         $jurisdictionProduct = $this->getEntityManager()->getRepository('GDI\\Entity\\TJurisdictionProduct')->findOneBy(array('marketProduct' => $marketproductId, 'jurisdiction' => $marketJurisdiction->getJurisdiction()->getJurisdictionId()));
         //var_dump($jurisdictionProduct->getRSubmissionDate());
         //exit;
         //var_dump($jurisdictionProduct);
         //$form->bind($jurisdictionProduct);
         $form->setName('jurisdictionProduct');
         $form->add(array('type' => 'Zend\\Form\\Element\\Date', 'name' => "jurs_prod[{$jurisAbbr}][eSubmissionDate]", 'options' => array('label' => 'Submission (Estimated)'), 'attributes' => array('value' => is_null($jurisdictionProduct) ? "" : $jurisdictionProduct->getESubmissionDate(), 'class' => 'form-control')));
         $form->add(array('type' => 'Zend\\Form\\Element\\Date', 'name' => "jurs_prod[{$jurisAbbr}][eApprovalDate]", 'options' => array('label' => 'Approval (Estimated)'), 'attributes' => array('value' => is_null($jurisdictionProduct) ? "" : $jurisdictionProduct->getEApprovalDate(), 'class' => 'form-control')));
         $form->add(array('type' => 'Zend\\Form\\Element\\Date', 'name' => "jurs_prod[{$jurisAbbr}][eReleaseDate]", 'options' => array('label' => 'Master Release (Estimated)'), 'attributes' => array('value' => is_null($jurisdictionProduct) ? "" : $jurisdictionProduct->getEReleaseDate(), 'class' => 'form-control')));
         $form->add(array('type' => 'Zend\\Form\\Element\\Date', 'name' => "jurs_prod[{$jurisAbbr}][eLaunchDate]", 'options' => array('label' => 'Launch (Estimated)'), 'attributes' => array('value' => is_null($jurisdictionProduct) ? "" : $jurisdictionProduct->getELaunchDate(), 'class' => 'form-control')));
         $form->add(array('type' => 'Zend\\Form\\Element\\Date', 'name' => "jurs_prod[{$jurisAbbr}][eRegulatorDate]", 'options' => array('label' => 'Regulator (Estimated)'), 'attributes' => array('value' => is_null($jurisdictionProduct) ? "" : $jurisdictionProduct->getERegulatorDate(), 'class' => 'form-control')));
         // result
         $form->add(array('type' => 'Zend\\Form\\Element\\Date', 'name' => "jurs_prod[{$jurisAbbr}][rSubmissionDate]", 'options' => array('label' => 'Submission (Result)'), 'attributes' => array('value' => is_null($jurisdictionProduct) ? "" : $jurisdictionProduct->getRSubmissionDate(), 'class' => 'form-control')));
         $form->add(array('type' => 'Zend\\Form\\Element\\Date', 'name' => "jurs_prod[{$jurisAbbr}][rApprovalDate]", 'options' => array('label' => 'Approval (Result)'), 'attributes' => array('value' => is_null($jurisdictionProduct) ? "" : $jurisdictionProduct->getRApprovalDate(), 'class' => 'form-control')));
         $form->add(array('type' => 'Zend\\Form\\Element\\Date', 'name' => "jurs_prod[{$jurisAbbr}][rReleaseDate]", 'options' => array('label' => 'Master Release (Result)'), 'attributes' => array('value' => is_null($jurisdictionProduct) ? "" : $jurisdictionProduct->getRReleaseDate(), 'class' => 'form-control')));
         $form->add(array('type' => 'Zend\\Form\\Element\\Date', 'name' => "jurs_prod[{$jurisAbbr}][rLaunchDate]", 'options' => array('label' => 'Launch (Result)'), 'attributes' => array('value' => is_null($jurisdictionProduct) ? "" : $jurisdictionProduct->getRLaunchDate(), 'class' => 'form-control')));
         $form->add(array('type' => 'Zend\\Form\\Element\\Date', 'name' => "jurs_prod[{$jurisAbbr}][rRegulatorDate]", 'options' => array('label' => 'Regulator (Result)'), 'attributes' => array('value' => is_null($jurisdictionProduct) ? "" : $jurisdictionProduct->getRRegulatorDate(), 'class' => 'form-control')));
         /*if ($key>0) {
               var_dump($key);
               break;
           }*/
     }
     $request = $this->getRequest();
     if ($request->isPost()) {
         $form->setData($request->getPost());
         if ($form->isValid()) {
             //var_dump($product);
         }
     }
     $view = new JsonModel(array('form' => $form, 'marketJurisdictions' => $marketJurisdictions));
     //$view->setTemplate('Application/InputProductInformation/jurisdictionproductform.phtml'); // path to phtml file under view folder
     $view->setTemplate('GDI/Index2/jurisdictionproductform.phtml');
     // path to phtml file under view folder
     return $view;
 }
 public function searchAction()
 {
     $request = $this->getRequest();
     if ($request->isPost()) {
         $queryText = $request->getPost()->get('query');
         $searchIndexLocation = $this->getIndexLocation();
         $index = Lucene\Lucene::open($searchIndexLocation);
         $searchResult = $index->find($queryText);
     }
     $form = new \Zend\Form\Form();
     $form->add(array('name' => 'query', 'attributes' => array('type' => 'text', 'id' => 'queryText'), 'options' => array('label' => 'Search String')));
     $form->add(array('name' => 'submit', 'attributes' => array('type' => 'submit', 'value' => 'Search')));
     $viewModel = new ViewModel(array('form' => $form, 'searchResults' => $searchResult));
     return $viewModel;
 }
 public function indexAction()
 {
     $user = $this->getLoggedInUser();
     $request = $this->getRequest();
     if ($request->isPost()) {
         $messageTest = $request->getPost()->get('message');
         $fromUserId = $user->getId();
         $this->sendMessage($messageTest, $fromUserId);
         // Для предотвращения дублирования записей при обновлении
         return $this->redirect()->toRoute('group-chat');
     }
     // Подготовка формы отправки сообщения
     $form = new \Zend\Form\Form();
     $form->add(array('name' => 'message', 'attributes' => array('type' => 'text', 'id' => 'messageText', 'required' => 'required'), 'options' => array('label' => 'Message')));
     $form->add(array('name' => 'submit', 'attributes' => array('type' => 'submit', 'value' => 'Send')));
     $form->add(array('name' => 'refresh', 'attributes' => array('type' => 'button', 'id' => 'btnRefresh', 'value' => 'Refresh')));
     $viewModel = new ViewModel(array('form' => $form, 'userName' => $user->getName()));
     return $viewModel;
 }
Example #16
0
 private function getFormAntennaModel($id)
 {
     $objectManager = $this->getServiceLocator()->get('Doctrine\\ORM\\EntityManager');
     $datas = array();
     $form = null;
     if ($id) {
         $antenna = $objectManager->getRepository('Application\\Entity\\Antenna')->find($id);
         if ($antenna) {
             $datas['antenna'] = $antenna;
             $qb = $objectManager->createQueryBuilder();
             $qb->select(array('p', 'c'))->from('Application\\Entity\\PredefinedEvent', 'p')->leftJoin('p.category', 'c')->andWhere('c INSTANCE OF Application\\Entity\\AntennaCategory');
             $models = array();
             foreach ($qb->getQuery()->getResult() as $model) {
                 foreach ($model->getCustomFieldsValues() as $value) {
                     if ($value->getCustomField()->getID() == $model->getCategory()->getAntennaField()->getId()) {
                         if ($value->getValue() == $id) {
                             $models[] = $model;
                         }
                     }
                 }
             }
             $form = new \Zend\Form\Form("model");
             $hidden = new \Zend\Form\Element\Hidden("id");
             $hidden->setValue($id);
             $form->add($hidden);
             $select = new \Zend\Form\Element\Select("models");
             $optionsModels = array();
             foreach ($models as $model) {
                 $optionsModels[$model->getId()] = $model->getName();
             }
             $select->setValueOptions($optionsModels);
             if (count($optionsModels) == 0) {
                 $select->setEmptyOption("Aucun modèle à associer");
             } else {
                 $select->setEmptyOption("Choisir le modèle à associer.");
             }
             $select->setLabel("Modèle : ");
             $form->add($select);
             $datas['form'] = $form;
         }
     }
     return $datas;
 }
 public function selectProfileFormAction()
 {
     $request = $this->getRequest();
     $form = new \Zend\Form\Form();
     $redirect = $this->params()->fromQuery("redirect", "");
     //load contact profile forms
     $arr_forms = $this->getContactsModel()->getContactProfileForm();
     //create radio button options
     foreach ($arr_forms as $key => $form_name) {
         $arr_element_value_options[$key] = $form_name;
     }
     //end foreach
     //add radio group to form
     $form->add(array("type" => "radio", "name" => "cpp_form_id", "options" => array("label" => "Please select the form you would like to use:", "value_options" => $arr_element_value_options)));
     //add remember option radio button
     $form->add(array('type' => 'checkbox', 'name' => 'remember_form', 'options' => array('label' => 'Remember my option', 'use_hidden_element' => true, 'checked_value' => '1', 'unchecked_value' => '0')));
     $form->add(array("name" => "submit", "attributes" => array("value" => "Submit"), "options" => array("ignore" => TRUE)));
     //check if local storage has been enabled
     $arr_config = $this->getServiceLocator()->get("config");
     if (!isset($arr_config["logged_in_user_settings"])) {
         $storage_disabled = TRUE;
     } elseif (isset($arr_config["logged_in_user_settings"]) && $arr_config["logged_in_user_settings"]["storage_enabled"] !== TRUE) {
         $storage_disabled = TRUE;
     }
     //end if
     if (isset($storage_disabled)) {
         $form->remove("remember_form");
     }
     //end if
     //load user session data
     $objUserStorage = FrontUserSession::getUserLocalStorageObject();
     if (is_numeric($objUserStorage->readUserNativePreferences()->cpp_form_id)) {
         $form->get("cpp_form_id")->setValue($objUserStorage->readUserNativePreferences()->cpp_form_id);
     }
     //end if
     if ($request->isPost()) {
         //validate form submitted
         $form->setData($request->getPost());
         if ($form->isValid()) {
             $arr_form_data = $form->getData();
             $form_id = $arr_form_data["cpp_form_id"];
             if (isset($arr_form_data["remember_form"]) && $arr_form_data["remember_form"] == 1) {
                 //persist user preference
                 if (is_object($objUserStorage)) {
                     $objUserStorage->setUserNativePreferences('cpp_form_id', $form_id);
                     $objUserData->cookie_data->cpp_form_id = $form_id;
                 }
                 //end if
             }
             //end if
             //check if redirect has been specified
             if ($redirect != "") {
                 //redirect received
                 return $this->redirect()->toUrl($redirect . "?fid={$form_id}");
             }
             //end if
             //redirect back to the contact edit screen with form id specified
             $url = $this->url()->fromRoute("front-contacts", array("action" => "create-contact"));
             //execute redirect
             $response = $this->getResponse();
             $response->getHeaders()->addHeaderLine('Location', $url . "?fid={$form_id}");
             $response->setStatusCode(302);
             return $response;
         }
         //end if
     }
     //end if
     return array("form" => $form, "redirect" => $redirect);
 }
Example #18
0
<?php

require_once '_init.php';
$form = new Zend\Form\Form();
$form->add(['type' => 'color', 'name' => 'color', 'options' => ['label' => 'Color', 'size' => 1]]);
$form->add(['type' => 'datetime', 'name' => 'datetime', 'options' => ['label' => 'DateTime', 'size' => 2]]);
$form->add(['type' => 'email', 'name' => 'email', 'options' => ['label' => 'Email', 'size' => 8]]);
$form->add(['type' => 'file', 'name' => 'file', 'options' => ['label' => 'File', 'size' => 8]]);
$form->add(['type' => 'month', 'name' => 'month', 'options' => ['label' => 'Month', 'size' => 3]]);
$form->add(['type' => 'number', 'name' => 'number', 'options' => ['label' => 'Number', 'size' => 8]]);
$form->add(['type' => 'password', 'name' => 'password', 'options' => ['label' => 'Password', 'size' => 8]]);
$form->add(['type' => 'select', 'name' => 'select', 'options' => ['label' => 'Select', 'size' => 8]]);
$form->add(['type' => 'text', 'name' => 'text', 'options' => ['label' => 'Text', 'size' => 8]]);
$form->add(['type' => 'textarea', 'name' => 'textarea', 'options' => ['label' => 'Textarea', 'size' => 8]]);
$form->add(['type' => 'url', 'name' => 'url', 'options' => ['label' => 'Url', 'size' => 8]]);
?>

<!DOCTYPE html>
<html>
<head>
    <?php 
$view->headLink()->appendStylesheet('css/bootstrap.css');
?>

    <?php 
echo $view->headLink();
?>
</head>
<body>
<div class="container">
    <div class="panel panel-warning">
 /**
  * Submit a webform
  * @return Ambigous <\Zend\Http\Response, \Zend\Stdlib\ResponseInterface>|Ambigous <unknown, \Zend\Form\Form>
  */
 public function bfAction()
 {
     //set container for additional params
     $arr_additional_params = array();
     $form_id = $this->params()->fromRoute("fid");
     $reg_id = $this->params()->fromRoute("reg_id", NULL);
     $arr_additional_params["reg_id"] = $reg_id;
     //check if reg id is encoded, if not, do not process
     if (is_numeric($reg_id)) {
         $this->flashMessenger()->addErrorMessage("An error occured attempting to load data");
         //redirect back to form
         return $this->redirect()->toRoute("majestic-external-forms/bf", array("fid" => $form_id));
     }
     //end if
     //load comm history id
     $comm_history_id = $this->params()->fromQuery("cid", "");
     if ($comm_history_id != "") {
         $arr_additional_params["cid"] = $comm_history_id;
     }
     //end if
     //check form id has been set
     if (!is_string($form_id)) {
         echo "Form could not be loaded. Required information is not available.";
         exit;
     }
     //end if
     try {
         //load form details
         $arr_return = $this->getExternalFormsModel()->loadForm($form_id, $reg_id, $arr_additional_params);
         $arr_return["additional_data"] = $arr_additional_params;
         //add plain form url
         $arr_return["form_url"] = $this->url()->fromRoute("majestic-external-forms/bf", array("fid" => $form_id));
     } catch (\Exception $e) {
         //@TODO do something with the error
         // var_dump($e->getMessage() . " : " . $e->getPrevious()); exit;
         die("The requested form could not be loaded. Response: " . $this->frontControllerErrorHelper()->formatErrors($e));
     }
     //end catch
     if ($arr_return["objFormRawData"]->secure_form == "1") {
         if (!isset($_SERVER['HTTPS']) || strtolower($_SERVER['HTTPS']) != "on" && $_SERVER["HTTPS"] != 1 && $_SERVER["SERVER_PORT"] != "443") {
             header("location:https://" . $_SERVER[HTTP_HOST] . $_SERVER[REQUEST_URI]);
         }
         //end if
     }
     //end if
     //should the user be logged in?
     if ($arr_return["objFormRawData"]->user_login == 1) {
         $objUserSession = FrontUserSession::isLoggedIn();
         if (!$objUserSession) {
             $this->flashMessenger()->addInfoMessage("User must be logged in in order to access form");
             //redirect to login screen
             return $this->redirect()->toRoute("front-user-login");
         }
         //end if
     }
     //end if
     //should the contact be specified
     if ($arr_return["objFormRawData"]->id_required == 1 && $reg_id == "") {
         echo "Form could not be loaded. Contact ID is not set";
         exit;
     }
     //end if
     //should the form be redirected on loading?
     if ($arr_return["objFormRawData"]->redirect_on_load != "") {
         header("location:" . $arr_return["objFormRawData"]->redirect_on_load);
         exit;
     }
     //end if
     //extract form from result
     $form = $arr_return["objForm"];
     //does form have password access enabled?
     //@TODO set proper session data
     if ($arr_return["objFormRawData"]->form_password != "" && $_SESSION["form_data"]["password"] != $arr_return["objFormRawData"]->form_password) {
         $form = new \Zend\Form\Form();
         $form->add(array("type" => "password", "name" => "password", "attributes" => array("id" => "password", "required" => "required"), "options" => array("label" => "Form Password")));
         $form->add(array("type" => "submit", "name" => "submit", "attributes" => array("value" => "Submit")));
         $request = $this->getRequest();
         if ($request->isPost()) {
             if ($request->getPost("password") == $arr_return["objFormRawData"]->form_password) {
                 $_SESSION["form_data"]["password"] = $request->getPost("password");
                 return $this->redirect()->toRoute("majestic-external-forms/bf", array("fid" => $form_id, "reg_id" => $reg_id));
             }
             //end if
         }
         //end if
         if ($_SESSION["form_data"]["password"] != $arr_return["objFormRawData"]->form_password) {
             $arr_return["form"] = $form;
             return $arr_return;
         }
         //end if
     }
     //end if
     //is form captcha enabled?
     if ($arr_return["objFormRawData"]->captcha == 1) {
         if (!is_dir("./public/captcha")) {
             mkdir("./public/captcha", 0755, TRUE);
         }
         //end if
         $objCaptcha = new \Zend\Captcha\Image(array('expiration' => '300', 'wordlen' => '7', 'font' => 'data/fonts/arial.ttf', 'fontSize' => '20', 'imgDir' => 'public/captcha', 'imgUrl' => '/captcha', 'lineNoiseLevel' => 1, 'dotNoiseLevel' => 1));
         $form->add(array("name" => "captcha", "type" => "Zend\\Form\\Element\\Captcha", "attributes" => array("id" => "captcha", "required" => "required", "autocomplete" => "off"), "options" => array("label" => "Human verification", "captcha" => $objCaptcha)));
     }
     //end if
     $arr_return["form_posted"] = FALSE;
     $request = $this->getRequest();
     if ($request->isPost()) {
         if ($form->has("captcha")) {
             if (!$objCaptcha->isValid($request->getPost("captcha"), $request->getPost())) {
                 $form->setData($request->getPost());
                 $this->flashMessenger()->addErrorMessage("CAPTCHA validation failed");
                 $arr_return["form"] = $form;
                 return $arr_return;
             }
             //end if
         }
         //end if
         //set form post flag to stop javascript loading on form error
         $arr_return["form_posted"] = TRUE;
         $form->setData($request->getPost());
         if ($form->isValid($request->getPost())) {
             try {
                 //submit the form
                 $objResult = $this->getExternalFormsModel()->processFormSubmit($form_id, $form->getData(), $arr_additional_params);
                 //unset form password
                 if (isset($_SESSION["form_data"]["password"])) {
                     unset($_SESSION["form_data"]["password"]);
                 }
                 //end if
                 //redirect to post submit page
                 return $this->redirect()->toRoute("majestic-external-forms/bfs", array("fid" => $form_id, "reg_id" => $objResult->data->reg_id_encoded));
             } catch (\Exception $e) {
                 //extract errors from the request return by the API
                 $arr_response = explode("||", $e->getMessage());
                 $objResponse = json_decode($arr_response[1]);
                 //check if user is logged in to display links to duplicate contacts
                 $objUserSession = FrontUserSession::isLoggedIn();
                 if (is_object($objResponse) && is_object($objUserSession)) {
                     switch ($objResponse->HTTP_RESPONSE_CODE) {
                         case 409:
                             //duplicates found
                             //extract message
                             $arr_t = explode(":", $objResponse->HTTP_RESPONSE_MESSAGE);
                             $id_string = array_pop($arr_t);
                             $this->flashMessenger()->addErrorMessage(trim(str_replace(array("{", "}"), "", $id_string)));
                             //extract ids and create links to each
                             preg_match('~{(.*?)}~', $id_string, $output);
                             $arr_contact_ids = explode(",", $output[1]);
                             if (is_array($arr_contact_ids) && count($arr_contact_ids) > 0) {
                                 foreach ($arr_contact_ids as $k => $id) {
                                     $this->flashMessenger()->addInfoMessage("<a href=\"" . $this->url()->fromRoute("front-contacts", array("action" => "view-contact", "id" => $id)) . "\" target=\"_blank\" title=\"View Contact\">Click to view duplicate {$id}</a>");
                                     if ($k > 19) {
                                         break;
                                     }
                                     //end if
                                 }
                                 //end foreach
                             }
                             //end if
                             break;
                         default:
                             //add errors to the form already where set
                             //@TODO this needs some work, messages  should be generated back into the form directly...
                             if (is_object($objResponse) && isset($objResponse->data)) {
                                 foreach ($objResponse->data as $k => $objField) {
                                     if (is_object($objField) && isset($objField->messages) && isset($objField->attributes->name)) {
                                         if ($form->has($objField->attributes->name)) {
                                             $arr_message = (array) $objField->messages;
                                             $form->get($objField->attributes->name)->setMessages($arr_message);
                                             $form->get($objField->attributes->name)->setValue($request->getPost($objField->attributes->name));
                                         }
                                         //end if
                                     }
                                     //end if
                                 }
                                 //end if
                             }
                             //end if
                             //set form errors
                             $form = $this->frontFormHelper()->formatFormErrors($form, $e->getMessage());
                             break;
                     }
                     //end switch
                 } else {
                     //@TODO this needs some work, messages  should be generated back into the form directly...
                     if (is_object($objResponse) && isset($objResponse->data)) {
                         foreach ($objResponse->data as $k => $objField) {
                             if (is_object($objField) && isset($objField->messages) && isset($objField->attributes->name)) {
                                 if ($form->has($objField->attributes->name)) {
                                     $arr_message = (array) $objField->messages;
                                     $form->get($objField->attributes->name)->setMessages($arr_message);
                                     $form->get($objField->attributes->name)->setValue($request->getPost($objField->attributes->name));
                                 }
                                 //end if
                             }
                             //end if
                         }
                         //end if
                     }
                     //end if
                     //set form errors
                     $form = $this->frontFormHelper()->formatFormErrors($form, $e->getMessage());
                 }
                 //end if
             }
             //end catch
         }
         //end if
     }
     //end if
     $arr_return["form"] = $form;
     $arr_return["form_id"] = $form_id;
     if ($reg_id != "") {
         $arr_return["reg_id"] = $reg_id;
     }
     //end if
     return $arr_return;
 }
Example #20
0
<?php

require_once './autoloader.php';
$translator = Zend\I18n\Translator\Translator::factory(array('locale' => 'zh', 'translation_file_patterns' => array('zf' => array('type' => 'PhpArray', 'base_dir' => EVA_LIB_PATH . '/Zend/resources/languages/', 'pattern' => '%s/Zend_Validate.php'))));
\Zend\Validator\AbstractValidator::setDefaultTranslator($translator);
$form = new \Zend\Form\Form();
$name = array('name' => 'username', 'options' => array('label' => 'Your name'), 'attributes' => array('type' => 'text'));
$form->add($name);
$filter = $form->getInputFilter();
$filter->remove('username');
$filter->add(array('name' => 'username', 'required' => true, 'validators' => array('stringLength' => array('name' => 'StringLength', 'options' => array('max' => '3')))));
$form->setInputFilter($filter);
//$form->prepare();
$form->setData(array('username' => 'sadjksafjas:'));
$form->prepare();
//p($form->getInputFilter());
$form->isValid();
p($form->getMessages());
Example #21
0
 public function analyzeClassAction()
 {
     $form = new \Zend\Form\Form();
     $form->setAttribute('method', 'post');
     $form->add(array('name' => 'class', 'attributes' => array('type' => 'text', 'class' => 'input-lg')));
     $form->add(array('name' => 'code', 'attributes' => array('type' => 'textarea', 'class' => 'input-lg', 'style' => 'width:900px;height:300px;')));
     $form->bind(new \ArrayObject($this->params()->fromPost()));
     $viewModel = new ViewModel();
     $viewModel->setVariable('form', $form);
     $code = $this->params()->fromPost('code');
     eval($code);
     $reflectedClass = new \ReflectionClass($this->params()->fromPost('class'));
     var_dump($reflectedClass->getMethods());
     return $viewModel;
 }
Example #22
0
<?php

require_once './autoloader.php';
$form = new \Zend\Form\Form();
$select = array('name' => 'cat_id', 'type' => 'Zend\\Form\\Element\\Select', 'options' => array('label' => 'Categoria', 'value_options' => array('' => '')));
$form->add($select);
$form->get('cat_id')->setValueOptions(array('foo' => 'bar'));
$helper = new Zend\Form\View\Helper\FormSelect();
echo $helper($form->get('cat_id'));
$formV = new \Zend\Form\Form();
$formV->add(array('name' => 'cat_id', 'type' => 'Zend\\Form\\Element\\Select', 'options' => array('label' => 'Categoria', 'value_options' => array('' => '')), 'require' => true, 'filters' => array(array('name' => 'Int'))));
$formV->setData(array('cat_id' => 'bar'));
$formV->prepare();
echo $formV->isValid();
Example #23
0
<?php

require_once './autoloader.php';
$value = array('title' => 'mytitle');
$value = new \ArrayObject($value);
$value['tag'] = new \ArrayObject(array('tagname' => 'mytag'));
$tagElement = array('name' => 'tagname', 'attributes' => array('type' => 'text', 'label' => 'Post Tag Name'));
$postElement = array('name' => 'title', 'attributes' => array('type' => 'text', 'label' => 'Post Title'));
$fieldset = new \Zend\Form\Fieldset('tag');
$fieldset->add($tagElement);
$form = new \Zend\Form\Form();
$form->add($postElement);
$form->add($fieldset);
$form->bind($value);
Example #24
0
<?php

require_once './autoloader.php';
$form = new \Zend\Form\Form();
$form->add(array('name' => 'username', 'type' => 'Zend\\Form\\Element\\Text'));
$subForm = new \Zend\Form\Form();
$subForm->setName('subform');
$subForm->add(array('name' => 'email', 'type' => 'Zend\\Form\\Element\\Text'));
$form->add($subForm);
$form->prepare();
$helper = new Zend\Form\View\Helper\FormText();
echo $helper($form->get('username'));
echo $helper($form->get('subform')->get('email'));
 /**
  *
  * Input filters for User Create
  *
  */
 private function addCreateUserFilters()
 {
     $this->form->getInputFilter()->add($this->form->getInputFilter()->getFactory()->createInput(array('name' => 'passwordVerify', 'filters' => array(array('name' => 'StripTags'), array('name' => 'StringTrim')), 'validators' => array(array('name' => 'StringLength', 'options' => array('encoding' => 'UTF-8', 'min' => 6, 'max' => 20)), array('name' => 'Identical', 'options' => array('token' => 'password'))))));
 }
    public function testDoesNotCreateNewObjects()
    {
        $form = new \Zend\Form\Form();
        $form->setHydrator(new \Zend\Stdlib\Hydrator\ClassMethods());
        $this->productFieldset->setUseAsBaseFieldset(true);
        $form->add($this->productFieldset);

        $product = new Product();
        $product->setName("foo");
        $product->setPrice(42);
        $cat1 = new \ZendTest\Form\TestAsset\Entity\Category();
        $cat1->setName("bar");
        $cat2 = new \ZendTest\Form\TestAsset\Entity\Category();
        $cat2->setName("bar2");

        $product->setCategories(array($cat1,$cat2));

        $form->bind($product);

        $form->setData(
            array("product"=>
                array(
                    "name" => "franz",
                    "price" => 13,
                    "categories" => array(
                        array("name" => "sepp"),
                        array("name" => "herbert")
                    )
                )
            )
        );
        $form->isValid();

        $categories = $product->getCategories();
        $this->assertSame($categories[0], $cat1);
        $this->assertSame($categories[1], $cat2);
    }
Example #27
0
<?php

require_once '_init.php';
$form = new \Zend\Form\Form();
$form->add(['name' => 'participants', 'type' => 'Zend\\Form\\Element\\Collection', 'options' => ['label' => 'Participants', 'should_create_template' => true, 'allow_add' => true, 'allow_remove' => true, 'count' => 1, 'template_placeholder' => '___' . uniqid() . '___', 'target_element' => ['name' => 'team', 'type' => 'Zend\\Form\\Fieldset', 'options' => ['label' => 'Team', 'size' => 10], 'elements' => [['spec' => ['name' => 'name', 'type' => 'text', 'options' => ['label' => 'Name', 'size' => 10]]], ['spec' => ['name' => 'players', 'type' => 'Zend\\Form\\Element\\Collection', 'options' => ['should_create_template' => true, 'count' => 1, 'label' => 'Players', 'template_placeholder' => '___' . uniqid() . '___', 'target_element' => ['name' => 'player', 'type' => 'Zend\\Form\\Fieldset', 'options' => ['label' => 'Player', 'size' => 10], 'elements' => [['spec' => ['name' => 'first_name', 'type' => 'text', 'options' => ['label' => 'First Name', 'size' => 10]]], ['spec' => ['name' => 'last_name', 'type' => 'text', 'options' => ['label' => 'Last Name', 'size' => 10]]], ['spec' => ['name' => 'email', 'type' => 'email', 'options' => ['label' => 'Email', 'size' => 10]]]]]]]]]]]]);
$form->add(['name' => 'fieldset', 'type' => 'Zend\\Form\\Fieldset', 'options' => ['label' => 'Another Fieldset', 'size' => 10], 'elements' => [['spec' => ['name' => 'datetime', 'type' => 'text', 'options' => ['label' => 'Foo', 'size' => 4, 'help' => 'Lorem ipsum dolor sit amet']]], ['spec' => ['name' => 'more', 'type' => 'file', 'options' => ['label' => 'Bar', 'size' => 4, 'help' => ['placement' => 'right', 'collapse' => true, 'text' => 'consectetur adipiscing elit']]]], ['spec' => ['name' => 'fields', 'type' => 'color', 'options' => ['label' => 'Baz', 'size' => 4, 'help' => 'Nam nulla odio, tincidunt vitae cursus sit amet, gravida eu lectus. Donec nec quam risus. Morbi vel posuere est. Phasellus scelerisque tortor erat, quis faucibus nisi malesuada at. Interdum et malesuada fames ac ante ipsum primis in faucibus. Aliquam convallis mauris sit amet congue mollis. Maecenas in sagittis erat, quis consectetur mi.']]]]]);
?>

<!DOCTYPE html>
<html>
<head>
    <link rel="stylesheet" href="css/bootstrap.css" media="screen"/>

    <style type="text/css">
        fieldset fieldset {
            margin-left: 2em;
        }
    </style>
</head>
<body>
<div class="container">
    <div class="panel panel-default">
        <div class="panel-heading">
            <h1 class="panel-title">
                Complex form with nested collections
            </h1>
        </div>

        <div class="panel-body">
            <?php 
echo $view->form()->setType('horizontal')->render($form->setAttribute('class', 'col-lg-offset-2 col-lg-8'));
 public function getRegisterForm()
 {
     $userForm = $this->getServiceLocator()->get('zfcuser_register_form');
     $userForm->setName('zfcuser');
     $userForm->remove('submit');
     $shippingAddressForm = $this->getServiceLocator()->get('SpeckAddress\\Form\\Address');
     $shippingAddressForm->setName('shipping')->setInputFilter($this->getServiceLocator()->get('SpeckAddress\\Form\\AddressFilter'));
     $billingAddressForm = $this->getServiceLocator()->get('SpeckAddress\\Form\\Address');
     $billingAddressForm->setName('billing')->setInputFilter($this->getServiceLocator()->get('SpeckAddress\\Form\\AddressFilter'));
     $form = new \Zend\Form\Form();
     $form->add($userForm)->add($shippingAddressForm)->add($billingAddressForm);
     return $form;
 }
Example #29
0
 public function testExtractFromObjectDoesntTouchOriginalObject()
 {
     $form = new \Zend\Form\Form();
     $form->setHydrator(new \Zend\Stdlib\Hydrator\ClassMethods());
     $this->productFieldset->setUseAsBaseFieldset(true);
     $form->add($this->productFieldset);
     $originalObjectHash = spl_object_hash($this->productFieldset->get("categories")->getTargetElement()->getObject());
     $product = new Product();
     $product->setName("foo");
     $product->setPrice(42);
     $cat1 = new \ZendTest\Form\TestAsset\Entity\Category();
     $cat1->setName("bar");
     $cat2 = new \ZendTest\Form\TestAsset\Entity\Category();
     $cat2->setName("bar2");
     $product->setCategories(array($cat1, $cat2));
     $form->bind($product);
     $form->setData(array("product" => array("name" => "franz", "price" => 13, "categories" => array(array("name" => "sepp"), array("name" => "herbert")))));
     $objectAfterExtractHash = spl_object_hash($this->productFieldset->get("categories")->getTargetElement()->getObject());
     $this->assertSame($originalObjectHash, $objectAfterExtractHash);
 }
 public function addAction()
 {
     //$tMarketProduct = new TMarketProduct();
     //$tProduct = new TProduct();
     $tMarketProduct = $this->getEntityManager()->find('GDI\\Entity\\TMarketProduct', 20);
     $tProduct = $this->getEntityManager()->find('GDI\\Entity\\TProduct', 5);
     $mGameCategory = new MGameCategory();
     //$builder = new AnnotationBuilder();
     $builder = new DoctrineAnnotationBuilder($this->getEntityManager());
     $form = $builder->createForm($tMarketProduct);
     foreach ($form->getElements() as $element) {
         if (method_exists($element, 'getProxy')) {
             $proxy = $element->getProxy();
             if (method_exists($proxy, 'setObjectManager')) {
                 $proxy->setObjectManager($this->getEntityManager());
             }
         }
     }
     $form->setHydrator(new DoctrineHydrator($this->getEntityManager(), 'GDI\\Entity\\TMarketProduct'));
     $form->bind($tMarketProduct);
     /*$form->get('market')->setOptions(
           array(
               'object_manager' => $this->getEntityManager(),
               'property'       => 'marketName',
           )
       );*/
     $storeOptions['find_method'] = array('name' => 'findBy', 'params' => array('criteria' => array(), 'orderBy' => array('marketName' => 'ASC')));
     $form->get('market')->setOptions($storeOptions);
     //$form->get('isActive')->setOptions(array('continue_if_empty' => true));
     /*$gameCategormForm = $builder->createForm($mGameCategory);
       $gameCategormForm->setName('gameCategormForm');*/
     $tProductForm = $builder->createForm($tProduct);
     //$tProductForm->setName('productForm');
     $tProductForm->setHydrator(new DoctrineHydrator($this->getEntityManager(), 'GDI\\Entity\\TProduct'));
     $tProductForm->bind($tProduct);
     $subForm = new \Zend\Form\Form();
     $subForm->setName('subform');
     $subForm->add(array('name' => 'email', 'type' => 'Zend\\Form\\Element\\Text'));
     //$form->add($tProductForm);
     //var_dump($form->get('productForm')->isValid());
     //var_dump($tProductForm->getName());
     //$form->add($subForm);
     /*$form->add(array(
           'type' => 'Zend\Form\Element\Select',
           'name' => 'gender',
           'options' => array(
               'label' => 'Gender',
               'value_options' => array(
                   '1' => 'Select your gender',
                   '2' => 'Female',
                   '3' => 'Male'
               ),
           ),
           'attributes' => array(
               'value' => '1' //set selected to '1'
           )
       ));*/
     //var_dump($form);exit;
     //$form->bind($tMarketProduct);
     $request = $this->getRequest();
     if ($request->isPost()) {
         var_dump($form->getAttributes());
         //var_dump($tProductForm->getHydrator()->extract($tProduct));
         //var_dump($tProductForm->getAttributes());
         //exit;
         $tMarketProduct->setCreateUserId(1);
         $tMarketProduct->setCreateTime(new \DateTime());
         $tMarketProduct->setUpdateUserId(1);
         //$tMarketProduct->setMarketProductId(null);
         $product = $this->getEntityManager()->find('GDI\\Entity\\TProduct', 1);
         $tMarketProduct->setProduct($product);
         //tproduct
         //$tProduct->setControlId(1);
         //$tProduct->setEArtworkSpDate(date('Y-m-d'));
         //$tProduct->setEArtworkTrDate(date('Y-m-d'));
         //$tProduct->setCreateUserId(1);
         //$tProduct->setCreateTime(new \DateTime());
         $tProduct->setUpdateUserId(1);
         $tProduct->setUpdateTime(new \DateTime());
         var_dump($request->getPost());
         //var_dump($form->get('productForm'));
         //exit
         //$form->remove('productForm');
         //$productFormClone = clone($tProductForm);
         //$form->remove('productForm');
         //$form->setInputFilter($tMarketProduct);
         $form->setData($request->getPost());
         $tProductForm->setData($request->getPost());
         //$form->setData($request->getPost());
         //$form->getFormFactory()->
         //$form->add($productFormClone);
         //$tProductForm = $productFormClone;
         //$tProductForm->setData($request->getPost());
         //var_dump($request->getPost());
         //var_dump($form->get('productForm'));
         //exit;
         /* if ($form->get('productForm')->isValid())
            {
                die('ok');
            }else {
            }*/
         //var_dump($form->get('TMarketProduct'));
         //$form->get('productForm')->setData($request->getPost());
         //var_dump($form->get('productForm')->isValid());
         if ($form->isValid() && $tProductForm->isValid()) {
             var_dump('ok form');
             //var_dump('asdf');
             //var_dump($form->getData());
             //exit;
             //$hydrator2 = new DoctrineHydrator($this->getEntityManager());
             //$tMarketProduct = new TMarketProduct();
             //$city = $hydrator2->hydrate($form->getData(), $tMarketProduct);
             //var_dump($city);exit;
             //var_dump($tMarketProduct);
             //var_dump($form->getData());
             $tProduct->setCreateUserId(1);
             $tProduct->setCreateTime(new \DateTime());
             $this->getEntityManager()->persist($tProductForm->getData());
             $this->getEntityManager()->flush();
             $tMarketProduct->setProduct($tProduct);
             $this->getEntityManager()->persist($form->getData());
             $this->getEntityManager()->flush();
             //var_dump($tProduct);
         } else {
         }
     }
     return array('form' => $form, 'tProductForm' => $tProductForm);
 }