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


PHP Zend_Form_Element::setOrder方法代码示例

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


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

示例1: insertBefore

 /**
  * Inserts $newElement right before $reference.
  *
  * @param Zend_Form $form
  * @param Zend_Form_Element $reference
  * @param Zend_Form_Element $newElement
  */
 protected function insertBefore(Zend_Form $form, Zend_Form_Element $reference, Zend_Form_Element $newElement)
 {
     /* @var $orderedElements array(Zend_Form_Element|Zend_Form|Zend_Form_DisplayGroup) */
     $orderedElements = array_values(iterator_to_array($form));
     // Ensure that each element has a numerical order value.
     $this->assignOrderValues($orderedElements);
     $buttonIndex = array_search($reference, $orderedElements, true);
     $buttonOrder = $orderedElements[$buttonIndex]->getOrder();
     if ($buttonIndex === 0) {
         // Button is the first element, therefore no previous element
         // whose order could be used for calculation exists.
         // Choose a constant value which ensures that the calculated
         // order value for the new element avoids re-ordering.
         $previousElementOrder = $buttonOrder - 2;
     } else {
         $previousElementOrder = $orderedElements[$buttonIndex - 1]->getOrder();
     }
     // Try to assign an order value between previous element and button order value.
     $newElementOrder = (int) round(($previousElementOrder + $buttonOrder) / 2);
     $newElement->setOrder($newElementOrder);
     // Insert $newElement at the position of the button.
     array_splice($orderedElements, $buttonIndex, 0, array($newElement));
     if ($newElementOrder === $buttonOrder) {
         // Order values clash, therefore a re-ordering of the elements
         // starting with the captcha is required.
         $elementsFromCaptcha = array_slice($orderedElements, $buttonIndex);
         $this->assignOrderValues($elementsFromCaptcha);
     }
     $this->reAssignElements($form, $orderedElements);
 }
开发者ID:matthimatiker,项目名称:molcomponents,代码行数:37,代码来源:Captcha.php


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