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


PHP Zend_Form::getSubForms方法代码示例

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


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

示例1: enableForm

 /**
  * Dojo-enable a form instance
  *
  * @param  Zend_Form $form
  * @return void
  */
 public static function enableForm(Zend_Form $form)
 {
     $form->addPrefixPath('Zend_Dojo_Form_Decorator', 'Zend/Dojo/Form/Decorator', 'decorator')->addPrefixPath('Zend_Dojo_Form_Element', 'Zend/Dojo/Form/Element', 'element')->addElementPrefixPath('Zend_Dojo_Form_Decorator', 'Zend/Dojo/Form/Decorator', 'decorator')->addDisplayGroupPrefixPath('Zend_Dojo_Form_Decorator', 'Zend/Dojo/Form/Decorator')->setDefaultDisplayGroupClass('Zend_Dojo_Form_DisplayGroup');
     foreach ($form->getSubForms() as $subForm) {
         self::enableForm($subForm);
     }
     if (null !== ($view = $form->getView())) {
         self::enableView($view);
     }
 }
开发者ID:georgepaul,项目名称:socialstrap,代码行数:16,代码来源:Dojo.php

示例2: enableForm

 /**
  * jQuery-enable a form instance
  *
  * @param  \Zend_Form $form
  * @return void
  */
 public static function enableForm(\Zend_Form $form)
 {
     $form->addPrefixPath('ZendX_JQuery_Form_Decorator', 'ZendX/JQuery/Form/Decorator', 'decorator')->addPrefixPath('ZendX_JQuery_Form_Element', 'ZendX/JQuery/Form/Element', 'element')->addElementPrefixPath('ZendX_JQuery_Form_Decorator', 'ZendX/JQuery/Form/Decorator', 'decorator')->addDisplayGroupPrefixPath('ZendX_JQuery_Form_Decorator', 'ZendX/JQuery/Form/Decorator');
     foreach ($form->getSubForms() as $subForm) {
         self::enableForm($subForm);
     }
     if (null !== ($view = $form->getView())) {
         self::enableView($view);
     }
 }
开发者ID:GemsTracker,项目名称:MUtil,代码行数:16,代码来源:JQuery.php

示例3: enhance

 /**
  * Adds unique IDs to all elements in the given form.
  *
  * @param Zend_Form $form
  */
 public function enhance(Zend_Form $form)
 {
     foreach ($form->getSubForms() as $subForm) {
         /* @var $subForm Zend_Form */
         $this->enhance($subForm);
     }
     foreach ($form->getElements() as $element) {
         /* @var $element Zend_Form_Element */
         $this->updateId($element);
     }
 }
开发者ID:matthimatiker,项目名称:molcomponents,代码行数:16,代码来源:UniqueId.php

示例4: _recurseForm

 /**
  * Recurse through a form object, rendering errors
  *
  * @param  \Zend_Form $form
  * @param  \Zend_View_Interface $view
  * @return string
  */
 protected function _recurseForm(\Zend_Form $form)
 {
     $subFormsWithErrors = array();
     $subFormMessages = array();
     $tabId = 0;
     foreach ($form->getSubForms() as $subForm) {
         if ($subForm instanceof \Gems_Form_TabSubForm) {
             // See if any of the subformelements has an error message
             foreach ($subForm->getElements() as $subFormElement) {
                 $elementMessages = $subFormElement->getMessages();
                 if (count($elementMessages)) {
                     $subFormsWithErrors[$tabId] = $subForm->getAttrib('title');
                     // Save subform title
                     $subForm->setAttrib('jQueryParams', array('class' => 'taberror'));
                     // Add css class to the subform
                     $form->selectTab($tabId);
                     // Select the tab, this way the last tab with error is always selected
                     break;
                     // don't check other elements
                 }
             }
             // Preserve subform level custom messages if we have an error
             if (array_key_exists($tabId, $subFormsWithErrors)) {
                 $subFormMessages[$tabId] = $subForm->getCustomMessages();
             }
             $tabId++;
         }
     }
     // If we found at least one error, and 'verbose' is true
     if ($this->getVerbose() && (!empty($subFormsWithErrors) || $form->isErrors())) {
         // First show form level custom error messages (the elements show their own errors)
         $formMessage = $form->getCustomMessages();
         if (!empty($formMessage)) {
             foreach ($formMessage as $message) {
                 \Zend_Controller_Action_HelperBroker::getStaticHelper('FlashMessenger')->addMessage($message);
             }
         }
         // Now browse through the tabs with errors
         foreach ($subFormsWithErrors as $tabIdx => $tabName) {
             // If more then one tab, show in which tab we found the errors
             if ($tabId > 1) {
                 $translator = \Zend_Registry::get('Zend_Translate');
                 \Zend_Controller_Action_HelperBroker::getStaticHelper('FlashMessenger')->addMessage(sprintf($translator->_('Error in tab "%s"'), $tabName));
             }
             // If we have them, show the tab custom error messages
             foreach ($subFormMessages[$tabIdx] as $subFormMessage) {
                 foreach ($subFormMessage as $message) {
                     \Zend_Controller_Action_HelperBroker::getStaticHelper('FlashMessenger')->addMessage("--> " . $message);
                 }
             }
         }
     }
 }
开发者ID:GemsTracker,项目名称:gemstracker-library,代码行数:60,代码来源:TabErrors.php

示例5: testCanSetAllSubFormDecoratorsAtOnce

 public function testCanSetAllSubFormDecoratorsAtOnce()
 {
     $this->setupSubForm();
     $this->form->setSubFormDecorators(array(array('Callback', array('callback' => 'strip_tags'))));
     foreach ($this->form->getSubForms() as $subForm) {
         $this->assertFalse($subForm->getDecorator('FormElements'));
         $this->assertFalse($subForm->getDecorator('HtmlTag'));
         $this->assertFalse($subForm->getDecorator('Fieldset'));
         $this->assertFalse($subForm->getDecorator('DtDdWrapper'));
         $decorator = $subForm->getDecorator('Callback');
         $this->assertTrue($decorator instanceof \Zend\Form\Decorator\Callback);
     }
 }
开发者ID:rafalwrzeszcz,项目名称:zf2,代码行数:13,代码来源:FormTest.php

示例6: prepareValidation

 /**
  * Bereitet die Validierung vor.
  * 
  * Zu jedem Language-Element in den Unterformularen wird ein zusätzlicher Validator hinzugefügt, der die POST Daten
  * für alle Unterformulare und die Position des Formulars mitbekommt, damit die Prüfung ausgeführt werden kann.
  * 
  * @param Zend_Form $form
  * @param array $data
  * @param array $context
  */
 public function prepareValidation($form, $data, $context = null)
 {
     $position = 0;
     $languages = $this->getSelectedLanguages($data);
     foreach ($form->getSubForms() as $name => $subform) {
         if (array_key_exists($name, $data)) {
             $element = $subform->getElement(Admin_Form_Document_Title::ELEMENT_LANGUAGE);
             if (!is_null($element)) {
                 $element->addValidator(new Form_Validate_LanguageUsedOnceOnly($languages, $position++));
             }
         }
     }
 }
开发者ID:alexukua,项目名称:opus4,代码行数:23,代码来源:RepeatedLanguages.php

示例7: _orderFormElements

 /**
  * Change form elements order to match query order
  *
  * @return void
  */
 private function _orderFormElements()
 {
     $hasCustomOrder = false;
     foreach ($this->_form->getSubForms() as $form) {
         foreach ($form->getElements() as $key => $element) {
             if (is_numeric($element->getOrder())) {
                 $hasCustomOrder = true;
                 break;
             }
         }
     }
     if ($hasCustomOrder === true) {
         return;
     }
     $fieldsOrder = array_flip($this->_fields);
     foreach ($this->_form->getSubForms() as $form) {
         $i = 100;
         foreach ($form->getElements() as $key => $element) {
             $fieldOrder = isset($fieldsOrder[$key]) ? $fieldsOrder[$key] : $i++;
             $element->setOrder($fieldOrder);
         }
     }
 }
开发者ID:ocpyosep78,项目名称:Booking,代码行数:28,代码来源:Table.php

示例8: _buildTable

 protected function _buildTable(Zend_Form $form)
 {
     # generate table header
     if ($this->_tableHeadersBuilt !== true) {
         if ($form instanceof Zend_Form_SubForm) {
             foreach ($form->getElements() as $eName => $e) {
                 if (isset($this->_tableHeaders[$eName])) {
                     throw new Exception(sprintf('Invalid sub-form (table row configuration) "%s" for table layout - table header already set for this column "%s"', $form->getName(), $eName));
                 }
                 $this->_tableHeaders[$eName] = $e->getLabel();
             }
             foreach ($form->getSubForms() as $formName => $subForm) {
                 $this->_buildTable($subForm);
             }
             return false;
         }
         # get headers from first sub-form
         $subform = $form->getSubForms();
         $subform = current($subform);
         $this->_buildTable($subform);
         $this->_tableHeadersBuilt = true;
     }
     if ($form instanceof Zend_Form_SubForm) {
         foreach ($form->getElements() as $eName => $e) {
             if ($this->getOption('doNotSetDecorators') !== true) {
                 $e->setDecorators(array('ViewHelper'));
             }
             if (isset($this->_tableCell[$eName])) {
                 throw new Exception(sprintf('Invalid sub-form (table row configuration) "%s" for table layout - table cell "%s" already set for row %d', $form->getName(), $eName, $this->_rowIndex));
             }
             $this->_tableCell[$eName] = $e;
         }
         foreach ($form->getSubForms() as $formName => $subForm) {
             $this->_buildTable($subForm);
         }
         return;
     }
     # $form is not instance of Zend_Form_SubForm
     $result = array();
     foreach ($form->getSubForms() as $formName => $subForm) {
         $this->_tableCell = array();
         $this->_rowIndex++;
         $this->_buildTable($subForm);
         if (empty($this->_tableCell)) {
             # no data generated from current subform
             continue;
         }
         $result[$this->_rowIndex] = $this->_tableCell;
     }
     if (empty($result)) {
         return '';
     }
     $tableRows = array();
     foreach ($result as $rowIndex => $row) {
         $elements = array();
         foreach ($this->_tableHeaders as $eName => $label) {
             if (!isset($row[$eName])) {
                 throw new Exception(sprintf('Invalid form "%s" for table layout - missing table cell "%s" for row %d', $form->getName(), $eName, $rowIndex));
             }
             # display messages in the same table cell as the input field
             $elements[] = implode('<br />', array_merge($row[$eName]->getMessages(), array($row[$eName]->render())));
         }
         $tableRows[] = '<tr><td>' . implode('</td><td>', $elements) . '</td></tr>' . "\n";
     }
     return '<table><tr><th>' . implode('</th><th>', $this->_tableHeaders) . '</th></tr>' . "\n" . implode('', $tableRows) . '</table>';
 }
开发者ID:Tony133,项目名称:zf-web,代码行数:66,代码来源:Table.php

示例9: setForm

 /**
  * Set a form instance
  *
  * @param Zend_Form $form
  * @return Zend_Controller_Action_Helper_MultiPageForm
  */
 public function setForm(Zend_Form $form)
 {
     $this->_form = $form;
     $subForms = $form->getSubForms();
     // Loop through all the subforms and check if they all have a name
     foreach ($subForms as $subForm) {
         $formName = $subForm->getName();
         if (empty($formName)) {
             /**
              * @see Zend_Controller_Action_Exception
              */
             require_once 'Zend/Controller/Action/Exception.php';
             throw new Zend_Controller_Action_Exception('A subform needs to have a name.');
         }
     }
     // Chaining
     return $this;
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:24,代码来源:MultiPageForm.php

示例10: getSubForms

 /**
  * Retrieve all form subForms/subforms
  *
  * @param bool $sort
  * @return array
  */
 public function getSubForms($sort = false)
 {
     if (!$sort) {
         return parent::getSubForms();
     } else {
         $this->_sort();
         $subForms = array();
         foreach ($this->_order as $key => $order) {
             $subForms[] = $this->getSubForm($key);
         }
         return $subForms;
     }
 }
开发者ID:uglide,项目名称:zfcore-transition,代码行数:19,代码来源:Multipage.php

示例11: testAddSubFormsPerConfig

 /**
  * @group ZF-5613
  */
 public function testAddSubFormsPerConfig()
 {
     // Create form
     $form = new Zend_Form(array('subForms' => array(array('form' => array('elements' => array('foo' => array('text', array('label' => 'Foo', 'decorators' => array('ViewHelper', 'Label')))), 'id' => 'subform1', 'decorators' => array('FormElements')), 'name' => 'subform1', 'order' => 2), array('form' => array('elements' => array('bar' => array('text', array('label' => 'Bar', 'decorators' => array('ViewHelper', 'Label')))), 'id' => 'subform2', 'decorators' => array('FormElements')), 'name' => 'subform2', 'order' => 1))));
     $form->removeDecorator('HtmlTag');
     // Tests
     $subForms = $form->getSubForms();
     $subForm1 = current($subForms);
     $subForm2 = next($subForms);
     $this->assertSame(array('subform1', 'subform2'), array($subForm1->getName(), $subForm2->getName()));
     $expected = '<form enctype="application/x-www-form-urlencoded" action="" method="post">' . PHP_EOL . PHP_EOL . '<label for="subform2-bar" class="optional">Bar</label>' . PHP_EOL . PHP_EOL . '<input type="text" name="subform2[bar]" id="subform2-bar" value="" />' . PHP_EOL . PHP_EOL . '<label for="subform1-foo" class="optional">Foo</label>' . PHP_EOL . PHP_EOL . '<input type="text" name="subform1[foo]" id="subform1-foo" value="" />' . '</form>';
     $this->assertSame($expected, $form->render($this->getView()));
 }
开发者ID:baofeng-beijing,项目名称:zf1.11.x,代码行数:16,代码来源:FormTest.php

示例12: getSubForms

 /**
  * Ermittelt alle Subformen (Subpages)
  * @return Myself_Form_Page_Interface
  */
 public function getSubForms()
 {
     $subForms = parent::getSubForms();
     $newForms = array();
     foreach ($subForms as $form) {
         if (!$form->isAvailable()) {
             // Remove form data from namespace
             unset($this->getNamespace()->{$form->getName()});
             continue;
         }
         $newForms[$form->getName()] = $form;
     }
     return $newForms;
 }
开发者ID:BowlingX,项目名称:Myself_Zend_Extensions,代码行数:18,代码来源:PageAble.php

示例13: setForm

 /**
  * Set a form instance
  *
  * @param Zend_Form $form
  * @return Zym_Controller_Action_Helper_MultiForm
  */
 public function setForm(Zend_Form $form)
 {
     $this->_form = $form;
     $subForms = $form->getSubForms();
     foreach ($subForms as $subForm) {
         $formName = $subForm->getName();
         if (empty($formName)) {
             /**
              * @see Zym_Controller_MultiPageForm_Exception_NoName
              */
             require_once 'Zym/Controller/Action/Helper/MultiPageForm/Exception/NoName.php';
             throw new Zym_Controller_MultiPageForm_Exception_NoName('A subform needs to have a name.');
         }
     }
     return $this;
 }
开发者ID:BGCX262,项目名称:zym-svn-to-git,代码行数:22,代码来源:MultiPageForm.php

示例14: subFormRender

 /**
  * Create an html code from form elements to render a plain text fom.<br />
  * This function filter subForms and create the read only view.<br />
  * Utilize the elementRender function to do the same with elements.<br />
  *
  * @param Zend_Form  $form  The form to transform into readOnlu view.
  *
  * @return string $this->_html The html code for the elements rendering.
  */
 public function subFormRender(Zend_Form $form, $subFormName = "")
 {
     $subForms = null;
     if (!$this->_listOpened) {
         $this->_html = $this->_openListTag;
         $this->_listOpened = true;
     }
     if (!empty($subFormName)) {
         $subForm = $form->getSubForm($subFormName);
         $this->_html .= $this->elementRender($subForm);
     } else {
         $subForms = $form->getSubForms();
         $nbSubForms = count($subForms);
         $position = 1;
         foreach ($subForms as $subForm) {
             $this->_html .= '<fieldset id = "' . $subForm->getId() . '" class="' . $subForm->getAttrib('class') . '">';
             $this->_html .= '<legend class="readOnly">';
             $this->_html .= $subForm->getLegend();
             $this->_html .= '</legend>';
             // Do not close the list after rendering elemnts of the sub forms.
             $this->_closeList = false;
             // Render sub form elements
             $this->_html .= $this->elementRender($subForm);
             $this->_html .= '</fieldset>';
             if ($this->_addSeparator && in_array($position, $this->_separatorPosition)) {
                 $this->_html .= '<div class="' . $this->_separatorClass . '"></div>';
             }
             $position++;
         }
         $this->_html .= $this->_closeListTag;
     }
     return $this->_html;
 }
开发者ID:anunay,项目名称:stentors,代码行数:42,代码来源:FormReadOnly.php


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