当前位置: 首页>>代码示例>>PHP>>正文


PHP Zend_Form::removeSubForm方法代码示例

本文整理汇总了PHP中Zend_Form::removeSubForm方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Form::removeSubForm方法的具体用法?PHP Zend_Form::removeSubForm怎么用?PHP Zend_Form::removeSubForm使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend_Form的用法示例。


在下文中一共展示了Zend_Form::removeSubForm方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testRemovingFormItemsShouldNotRaiseExceptionsDuringIteration

 public function testRemovingFormItemsShouldNotRaiseExceptionsDuringIteration()
 {
     $this->setupElements();
     $bar = $this->form->bar;
     $this->form->removeElement('bar');
     try {
         foreach ($this->form as $item) {
         }
     } catch (Exception $e) {
         $this->fail('Exceptions should not be raised by iterator when elements are removed; error message: ' . $e->getMessage());
     }
     $this->form->addElement($bar);
     $this->form->addDisplayGroup(array('baz', 'bar'), 'bazbar');
     $this->form->removeDisplayGroup('bazbar');
     try {
         foreach ($this->form as $item) {
         }
     } catch (Exception $e) {
         $this->fail('Exceptions should not be raised by iterator when elements are removed; error message: ' . $e->getMessage());
     }
     $subForm = new Zend_Form_SubForm();
     $subForm->addElements(array('foo' => 'text', 'bar' => 'text'));
     $this->form->addSubForm($subForm, 'page1');
     $this->form->removeSubForm('page1');
     try {
         foreach ($this->form as $item) {
         }
     } catch (Exception $e) {
         $this->fail('Exceptions should not be raised by iterator when elements are removed; error message: ' . $e->getMessage());
     }
 }
开发者ID:vicfryzel,项目名称:zf,代码行数:31,代码来源:FormTest.php

示例2: reAssignElements

 /**
  * Explicitly removes and re-adds elements to the provided form to
  * ensure that the form re-builds the element order.
  *
  * Due to a bug this is required if the order of an element is
  * changed after the internal form index was created:
  * {@link http://framework.zend.com/issues/browse/ZF-9946}
  *
  * @param Zend_Form $form
  * @param array(Zend_Form_Element|Zend_Form|Zend_Form_DisplayGroup) $elements
  */
 protected function reAssignElements(Zend_Form $form, array $elements)
 {
     $elementsByType = $this->categorizeElements($elements);
     foreach ($elementsByType['elements'] as $element) {
         /* @var $element Zend_Form_Element */
         $form->removeElement($element->getName());
         $form->addElement($element);
     }
     foreach ($elementsByType['subForms'] as $subForm) {
         /* @var $subForm Zend_Form */
         $form->removeSubForm($subForm->getName());
         $form->addSubForm($subForm, $subForm->getName());
     }
     foreach ($elementsByType['displayGroups'] as $displayGroup) {
         /* @var $displayGroup Zend_Form_DisplayGroup */
         $form->removeDisplayGroup($displayGroup->getName());
         $form->addDisplayGroup($displayGroup->getElements(), $displayGroup->getName());
     }
 }
开发者ID:matthimatiker,项目名称:molcomponents,代码行数:30,代码来源:Captcha.php

示例3: _processForm

 /**
  * Process all information forms related
  * First we check for permissions to add, edit, delete
  * And then the request->isPost. If true we process the data
  *
  * @return Bvb_Grid_Deploy_Table
  */
 protected function _processForm()
 {
     if (!$this->getSource()->hasCrud()) {
         return false;
     }
     if ($this->getInfo("add,allow") == 1) {
         $this->_allowAdd = 1;
     }
     if ($this->getInfo("delete,allow") == 1) {
         $this->_allowDelete = 1;
     }
     if ($this->getInfo("edit,allow") == 1) {
         $this->_allowEdit = 1;
     }
     if ($this->_allowEdit == 1 || $this->_allowDelete == 1) {
         $dec = $this->getParam('comm');
     }
     /**
      * Remove if there is something to remove
      */
     if ($this->_allowDelete == 1) {
         self::_deleteRecord($dec);
     }
     $opComm = $this->getParam('comm');
     $mode = $this->getParam('edit') ? 'edit' : 'add';
     //Check if the request method is POST
     if ($this->getRequest()->isPost() && $this->getRequest()->getPost('zfg_form_edit' . $this->getGridId()) == 1) {
         foreach ($this->_form->getSubForms() as $key => $form) {
             if (isset($_POST[$key]['ZFIGNORE']) && $_POST[$key]['ZFIGNORE'] == 1) {
                 $this->_form->removeSubForm($key);
             }
         }
         if (count($this->_form->getSubForms()) == 0) {
             $this->_redirect($this->getUrl(array('zfg_csrf', 'add', 'zfg_form_edit', 'form_submit')));
         }
         if ($this->_form->isValid($_POST)) {
             $post = array();
             foreach ($this->_form->getSubForms() as $key => $value) {
                 foreach ($value->getElements() as $el) {
                     $fieldValue = $el->getValue();
                     $post[$key][$el->getName()] = is_array($fieldValue) ? implode(',', $fieldValue) : $fieldValue;
                 }
                 unset($post[$key]['ZFIGNORE']);
             }
             $addNew = false;
             if (isset($_POST['saveAndAdd' . $this->getGridId()])) {
                 $this->_gridSession->noErrors = true;
                 $addNew = true;
             }
             unset($post['form_submit' . $this->getGridId()]);
             unset($post['zfg_form_edit' . $this->getGridId()]);
             unset($post['form_reset' . $this->getGridId()]);
             unset($post['zfg_csrf' . $this->getGridId()]);
             unset($post['saveAndAdd' . $this->getGridId()]);
             // Process data
             if ($mode == 'add') {
                 try {
                     foreach ($this->_form->getSubForms() as $key => $value) {
                         if ($this->_crud->getUseVerticalInputs() === false && $key == 0) {
                             continue;
                         }
                         $sendCall = array(&$post[$key], $this->getSource());
                         if (null !== $this->_callbackBeforeInsert) {
                             call_user_func_array($this->_callbackBeforeInsert, $sendCall);
                         }
                         //Let's see if the field is nullable and empty
                         //If so, we need to remove it from the array
                         $tableFields = $this->getSource()->getDescribeTable($this->_crudTable);
                         foreach (array_keys($post[$key]) as $field) {
                             if ($tableFields[$field]['NULLABLE'] == 1 && strlen($post[$key][$field]) == 0) {
                                 unset($post[$key][$field]);
                             }
                         }
                         if ($this->_crudTableOptions['add'] == true) {
                             $post[$key] = array_merge($post[$key], $this->_crudOptions['addForce']);
                             $sendCall[] = $this->getSource()->insert($this->_crudTable, $post[$key]);
                         }
                         if (null !== $this->_callbackAfterInsert) {
                             call_user_func_array($this->_callbackAfterInsert, $sendCall);
                         }
                         unset($this->_gridSession->post[$key]);
                     }
                     $this->_gridSession->message = $this->__('Record saved');
                     $this->_gridSession->messageOk = true;
                     if (isset($post['saveAndAdd' . $this->getGridId()])) {
                         $this->_gridSession->_noForm = 0;
                     } else {
                         $this->_gridSession->_noForm = 1;
                     }
                     $this->_gridSession->correct = 1;
                     $this->_removeFormParams(array('add' . $this->getGridId() => '1'));
                     if ($addNew === true) {
                         $finalUrl = '/add' . $this->getGridId() . '/1';
//.........这里部分代码省略.........
开发者ID:robjacoby,项目名称:xlr8u,代码行数:101,代码来源:Table.php

示例4: _processForm

 /**
  * Process all information forms related
  * First we check for permissions to add, edit, delete
  * And then the request->isPost. If true we process the data
  *
  * @return Bvb_Grid_Deploy_Table
  */
 protected function _processForm()
 {
     if (!$this->getSource()->hasCrud()) {
         return false;
     }
     if ($this->getInfo("add,allow") == 1) {
         $this->_allowAdd = 1;
     }
     if ($this->getInfo("delete,allow") == 1) {
         $this->_allowDelete = 1;
     }
     if ($this->getInfo("edit,allow") == 1) {
         $this->_allowEdit = 1;
     }
     /**
      * Remove if there is something to remove
      */
     if ($this->_allowDelete == 1 && ($this->getParam('delete') || $this->getParam('zfmassremove')) && !$this->getParam('detail')) {
         self::_deleteRecord();
     }
     $mode = $this->getParam('edit') ? 'edit' : 'add';
     //Check if the request method is POST
     if ($this->getRequest()->isPost() && $this->getRequest()->getPost('zfg_form_edit' . $this->getGridId()) == 1) {
         foreach ($this->_form->getSubForms() as $key => $form) {
             if (isset($_POST[$key]['ZFIGNORE']) && $_POST[$key]['ZFIGNORE'] == 1) {
                 $this->_form->removeSubForm($key);
             }
         }
         if (count($this->_form->getSubForms()) == 0) {
             $this->_redirect($this->getUrl(array('zfg_csrf', 'add', 'zfg_form_edit', 'form_submit')));
         }
         if ($this->_form->isValid($_POST)) {
             $post = array();
             foreach ($this->_form->getSubForms() as $key => $value) {
                 foreach ($value->getElements() as $el) {
                     if ($el->getIgnore()) {
                         continue;
                     }
                     $fieldValue = $el->getValue();
                     $post[$key][$el->getName()] = is_array($fieldValue) ? implode(',', $fieldValue) : $fieldValue;
                 }
                 unset($post[$key]['ZFIGNORE']);
             }
             $addNew = false;
             if (isset($_POST['saveAndAdd' . $this->getGridId()])) {
                 $this->_gridSession->noErrors = true;
                 $addNew = true;
             }
             unset($post['form_submit' . $this->getGridId()]);
             unset($post['zfg_form_edit' . $this->getGridId()]);
             unset($post['form_reset' . $this->getGridId()]);
             unset($post['zfg_csrf' . $this->getGridId()]);
             unset($post['saveAndAdd' . $this->getGridId()]);
             // Process data
             if ($mode == 'add') {
                 $this->getSource()->beginTransaction();
                 try {
                     foreach ($this->_form->getSubForms() as $key => $value) {
                         if ($this->_crud->getUseVerticalInputs() === false && $key == 0) {
                             continue;
                         }
                         //Let's see if the field is nullable and empty
                         //If so, we need to remove it from the array
                         $tableFields = $this->getSource()->getDescribeTable($this->_crudTable);
                         foreach (array_keys($post[$key]) as $field) {
                             if (!isset($tableFields[$field])) {
                                 continue;
                             }
                             if ($tableFields[$field]['NULLABLE'] == 1 && strlen($post[$key][$field]) == 0) {
                                 $post[$key][$field] = new Zend_Db_Expr("NULL");
                             }
                         }
                         if (count($post[$key]) == 0) {
                             throw new Bvb_Grid_Exception($this->__('No values to insert'));
                         }
                         $post[$key] = array_merge($post[$key], $this->_crudOptions['addForce']);
                         $this->emitEvent('crud.before_insert', array('table' => &$this->_crudTable, 'connectionId' => $this->getSource()->getConnectionId(), 'values' => &$post[$key]));
                         if ($this->_crudTableOptions['add'] == true) {
                             $insertId = $this->getSource()->insert($this->_crudTable, $post[$key]);
                         } else {
                             $insertId = '';
                         }
                         $this->emitEvent('crud.after_insert', array('table' => &$this->_crudTable, 'connectionId' => $this->getSource()->getConnectionId(), 'values' => &$post[$key], 'insertId' => $insertId));
                         unset($this->_gridSession->post[$key]);
                     }
                     $this->getSource()->commit();
                     $this->_gridSession->message = $this->__('Record saved');
                     $this->_gridSession->messageOk = true;
                     if (isset($post['saveAndAdd' . $this->getGridId()])) {
                         $this->_gridSession->_noForm = 0;
                     } else {
                         $this->_gridSession->_noForm = 1;
                     }
//.........这里部分代码省略.........
开发者ID:ocpyosep78,项目名称:Booking,代码行数:101,代码来源:Table.php

示例5: _formStepCommonPopulate


//.........这里部分代码省略.........
                 }
                 if ($quoteManager->hasProduct(Manager_Insurance_LandlordsPlus_Quote::CONTENTS_COVER) || $quoteManager->hasProduct(Manager_Insurance_LandlordsPlus_Quote::UNFURNISHED_CONTENTS_COVER)) {
                     $formData['need_contents_insurance'] = 'yes';
                     if ($quoteManager->hasProduct(Manager_Insurance_LandlordsPlus_Quote::CONTENTS_COVER)) {
                         $formData['property_furnished'] = 'yes';
                         $productMeta = $quoteManager->getProductMeta(Manager_Insurance_LandlordsPlus_Quote::CONTENTS_COVER);
                         $formData['contents_amount'] = $productMeta['cover_amount'];
                         $formData['contents_excess'] = $productMeta['excess'];
                         $formData['contents_accidental_damage'] = $productMeta['accidental_damage'];
                     } else {
                         $formData['property_furnished'] = 'no';
                     }
                 }
                 break;
             case 3:
                 if (isset($pageSession->completed[$stepNum]) && $pageSession->completed[$stepNum] == true) {
                     $formData['need_emergency_assistance'] = 'no';
                     $formData['need_prestige_rent_guarantee'] = 'no';
                     $formData['need_legal_expenses'] = 'no';
                     $formData['need_boiler_heating'] = 'no';
                 }
                 // If we have contents/buildings cover then EAS is already included for free so we can hide the form
                 if ($quoteManager->hasProduct(Manager_Insurance_LandlordsPlus_Quote::BUILDING_COVER) || $quoteManager->hasProduct(Manager_Insurance_LandlordsPlus_Quote::CONTENTS_COVER)) {
                     // Change the subforms view script to one that just says it's already included for free
                     // yeah yeah.. this aint pretty :(
                     $emergencyAssistanceForm = $pageForm->getSubForm('subform_emergencyassistance');
                     $emergencyAssistanceForm->setDecorators(array(array('ViewScript', array('viewScript' => 'subforms/emergency-assistance-free.phtml'))));
                     if ($quoteManager->hasProduct(Manager_Insurance_LandlordsPlus_Quote::BOILER_HEATING)) {
                         $formData['need_boiler_heating'] = 'yes';
                     }
                 } else {
                     // We can allow stand-alone EAS - so we hide the boiler and heating section
                     // yes... this is waaay too complex... I know :(
                     $pageForm->removeSubForm('subform_boilerheating');
                     if ($quoteManager->hasProduct(Manager_Insurance_LandlordsPlus_Quote::EMERGENCY_ASSISTANCE)) {
                         $formData['need_emergency_assistance'] = 'yes';
                     }
                 }
                 if ($quoteManager->hasProduct(Manager_Insurance_LandlordsPlus_Quote::RENT_GUARANTEE)) {
                     $formData['need_prestige_rent_guarantee'] = 'yes';
                     $productMeta = $quoteManager->getProductMeta(Manager_Insurance_LandlordsPlus_Quote::RENT_GUARANTEE);
                     $formData['rent_amount'] = $productMeta['monthly_rent'];
                 } elseif ($quoteManager->hasProduct(Manager_Insurance_LandlordsPlus_Quote::LEGAL_EXPENSES)) {
                     $formData['need_legal_expenses'] = 'yes';
                 }
                 break;
             case 4:
                 if (isset($pageSession->completed[$stepNum]) && $pageSession->completed[$stepNum] == true) {
                     // Load underwriting answers from the database as they've already been answered
                     $answersManager = new Manager_Insurance_Answers();
                     $quote = $quoteManager->getModel();
                     $policyNumber = $quote->legacyID;
                     $customerReferenceNumber = $quote->legacyCustomerID;
                     $answers = $answersManager->getUnderwritingAnswers($policyNumber);
                     foreach ($answers as $answer) {
                         switch ($answer->getQuestionNumber()) {
                             case '53':
                                 $formData['declaration1'] = $answer->getAnswer();
                                 break;
                             case '54':
                                 $formData['declaration2'] = $answer->getAnswer();
                                 break;
                             case '55':
                                 $formData['declaration2b'] = $answer->getAnswer();
                                 break;
                             case '56':
开发者ID:AlexEvesDeveloper,项目名称:hl-stuff,代码行数:67,代码来源:IndexController.php


注:本文中的Zend_Form::removeSubForm方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。