Example #1
0
 /**
  * {@inheritDoc}
  */
 public function setName($name)
 {
     parent::setName($name);
     if ($this->has($this->getCaptchaElementName())) {
         $element = $this->get($this->getCaptchaElementName());
         $this->captchaElementName = null;
         $name = $element->getName();
         $newName = $this->getCaptchaElementName();
         $flags['priority'] = $this->iterator->toArray(PriorityList::EXTR_PRIORITY)[$name];
         $this->remove($name);
         $element->setName($newName);
         $this->add($element, $flags);
     }
     if ($this->has($this->getCsrfElementName())) {
         $element = $this->get($this->getCsrfElementName());
         $this->csrfElementName = null;
         $name = $element->getName();
         $newName = $this->getCsrfElementName();
         $flags['priority'] = $this->iterator->toArray(PriorityList::EXTR_PRIORITY)[$name];
         $this->remove($name);
         $element->getCsrfValidator()->setName($newName);
         $element->setName($newName);
         $this->add($element, $flags);
     }
     return $this;
 }
Example #2
0
File: Form.php Project: rikaix/zf2
 /**
  * Add a form group/subform
  *
  * @param  Form $form
  * @param  string $name
  * @param  int $order
  * @return Form
  */
 public function addSubForm(Form $form, $name, $order = null)
 {
     $name = (string) $name;
     foreach ($this->_loaders as $type => $loader) {
         $loaderPaths = $loader->getPaths();
         foreach ($loaderPaths as $prefix => $paths) {
             foreach ($paths as $path) {
                 $form->addPrefixPath($prefix, $path, $type);
             }
         }
     }
     if (!empty($this->_elementPrefixPaths)) {
         foreach ($this->_elementPrefixPaths as $spec) {
             list($prefix, $path, $type) = array_values($spec);
             $form->addElementPrefixPath($prefix, $path, $type);
         }
     }
     if (!empty($this->_displayGroupPrefixPaths)) {
         foreach ($this->_displayGroupPrefixPaths as $spec) {
             list($prefix, $path) = array_values($spec);
             $form->addDisplayGroupPrefixPath($prefix, $path);
         }
     }
     if (null !== $order) {
         $form->setOrder($order);
     }
     if (($oldName = $form->getName()) && $oldName !== $name && $oldName === $form->getElementsBelongTo()) {
         $form->setElementsBelongTo($name);
     }
     $form->setName($name);
     $this->_subForms[$name] = $form;
     $this->_order[$name] = $order;
     $this->_orderUpdated = true;
     return $this;
 }
 public function testAction()
 {
     /*$form = new CreateProduct();
       $product = new Product();
       $form->bind($product);*/
     $form = new \Zend\Form\Form();
     $marketJurisdictions = $this->getEntityManager()->getRepository('GDI\\Entity\\RMarketJurisdiction')->findByMarket('1');
     //var_dump($marketJurisdiction);
     //exit;
     foreach ($marketJurisdictions as $marketJurisdiction) {
         //var_dump($marketJurisdiction->getJurisdiction());
         $jurisAbbr = $marketJurisdiction->getJurisdiction()->getJurisdictionAbbr();
         $form->setName('jurisdictionProduct');
         $form->add(array('type' => 'Zend\\Form\\Element\\Date', 'name' => 'eSubmissionDate' . $jurisAbbr, 'options' => array('label' => 'Submission (Estimated)')));
         $form->add(array('type' => 'Zend\\Form\\Element\\Date', 'name' => 'eApprovalDate' . $jurisAbbr, 'options' => array('label' => 'Approval (Estimated)')));
         $form->add(array('type' => 'Zend\\Form\\Element\\Date', 'name' => 'eReleaseDate' . $jurisAbbr, 'options' => array('label' => 'Master Release (Estimated)')));
         $form->add(array('type' => 'Zend\\Form\\Element\\Date', 'name' => 'eLaunchDate' . $jurisAbbr, 'options' => array('label' => 'Launch (Estimated)')));
         $form->add(array('type' => 'Zend\\Form\\Element\\Date', 'name' => 'eRegulatorDate' . $jurisAbbr, 'options' => array('label' => 'Regulator (Estimated)')));
         // result
         $form->add(array('type' => 'Zend\\Form\\Element\\Date', 'name' => 'rSubmissionDate' . $jurisAbbr, 'options' => array('label' => 'Submission (Result)')));
         $form->add(array('type' => 'Zend\\Form\\Element\\Date', 'name' => 'rApprovalDate' . $jurisAbbr, 'options' => array('label' => 'Approval (Result)')));
         $form->add(array('type' => 'Zend\\Form\\Element\\Date', 'name' => 'rReleaseDate' . $jurisAbbr, 'options' => array('label' => 'Master Release (Result)')));
         $form->add(array('type' => 'Zend\\Form\\Element\\Date', 'name' => 'rLaunchDate' . $jurisAbbr, 'options' => array('label' => 'Launch (Result)')));
         $form->add(array('type' => 'Zend\\Form\\Element\\Date', 'name' => 'rRegulatorDate' . $jurisAbbr, 'options' => array('label' => 'Regulator (Result)')));
     }
     /*$subForm = new \Zend\Form\Form();
             $subForm->setName('subform');
     
             $subForm->add(array(
                 'name' => 'email',
                 'type' => 'Zend\Form\Element\Text',
             ));*/
     $request = $this->getRequest();
     if ($request->isPost()) {
         $form->setData($request->getPost());
         if ($form->isValid()) {
             //var_dump($product);
         }
     }
     $view = new ViewModel(array('form' => $form, 'marketJurisdictions' => $marketJurisdictions));
     $view->setTemplate('GDI/Index2/productForm2.phtml');
     // path to phtml file under view folder
     return $view;
 }