當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ElementInterface::shouldShowSeconds方法代碼示例

本文整理匯總了PHP中Zend\Form\ElementInterface::shouldShowSeconds方法的典型用法代碼示例。如果您正苦於以下問題:PHP ElementInterface::shouldShowSeconds方法的具體用法?PHP ElementInterface::shouldShowSeconds怎麽用?PHP ElementInterface::shouldShowSeconds使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Zend\Form\ElementInterface的用法示例。


在下文中一共展示了ElementInterface::shouldShowSeconds方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: render

 /**
  * Render a date element that is composed of six selects
  *
  * @param  ElementInterface $element
  * @throws \Zend\Form\Exception\InvalidArgumentException
  * @throws \Zend\Form\Exception\DomainException
  * @return string
  */
 public function render(ElementInterface $element)
 {
     if (!$element instanceof DateTimeSelectElement) {
         throw new Exception\InvalidArgumentException(sprintf('%s requires that the element is of type Zend\\Form\\Element\\DateTimeSelect', __METHOD__));
     }
     $name = $element->getName();
     if ($name === null || $name === '') {
         throw new Exception\DomainException(sprintf('%s requires that the element has an assigned name; none discovered', __METHOD__));
     }
     $shouldRenderDelimiters = $element->shouldRenderDelimiters();
     $selectHelper = $this->getSelectElementHelper();
     $pattern = $this->parsePattern($shouldRenderDelimiters);
     $daysOptions = $this->getDaysOptions($pattern['day']);
     $monthsOptions = $this->getMonthsOptions($pattern['month']);
     $yearOptions = $this->getYearsOptions($element->getMinYear(), $element->getMaxYear());
     $hourOptions = $this->getHoursOptions($pattern['hour']);
     $minuteOptions = $this->getMinutesOptions($pattern['minute']);
     $secondOptions = $this->getSecondsOptions($pattern['second']);
     $dayElement = $element->getDayElement()->setValueOptions($daysOptions);
     $monthElement = $element->getMonthElement()->setValueOptions($monthsOptions);
     $yearElement = $element->getYearElement()->setValueOptions($yearOptions);
     $hourElement = $element->getHourElement()->setValueOptions($hourOptions);
     $minuteElement = $element->getMinuteElement()->setValueOptions($minuteOptions);
     $secondElement = $element->getSecondElement()->setValueOptions($secondOptions);
     if ($element->shouldCreateEmptyOption()) {
         $dayElement->setEmptyOption('');
         $yearElement->setEmptyOption('');
         $monthElement->setEmptyOption('');
         $hourElement->setEmptyOption('');
         $minuteElement->setEmptyOption('');
         $secondElement->setEmptyOption('');
     }
     $data = array();
     $data[$pattern['day']] = $selectHelper->render($dayElement);
     $data[$pattern['month']] = $selectHelper->render($monthElement);
     $data[$pattern['year']] = $selectHelper->render($yearElement);
     $data[$pattern['hour']] = $selectHelper->render($hourElement);
     $data[$pattern['minute']] = $selectHelper->render($minuteElement);
     if ($element->shouldShowSeconds()) {
         $data[$pattern['second']] = $selectHelper->render($secondElement);
     } else {
         unset($pattern['second']);
         if ($shouldRenderDelimiters) {
             unset($pattern[4]);
         }
     }
     $markup = '';
     foreach ($pattern as $key => $value) {
         // Delimiter
         if (is_numeric($key)) {
             $markup .= $value;
         } else {
             $markup .= $data[$value];
         }
     }
     $markup = trim($markup);
     return $markup;
 }
開發者ID:jjs180,項目名稱:dance-america,代碼行數:66,代碼來源:FormDateTimeSelect.php


注:本文中的Zend\Form\ElementInterface::shouldShowSeconds方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。