Ejemplo n.º 1
0
 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);
 }
 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;
 }
Ejemplo n.º 3
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'));