本文整理汇总了PHP中Zend\Form\ElementInterface::getDayElement方法的典型用法代码示例。如果您正苦于以下问题:PHP ElementInterface::getDayElement方法的具体用法?PHP ElementInterface::getDayElement怎么用?PHP ElementInterface::getDayElement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Form\ElementInterface
的用法示例。
在下文中一共展示了ElementInterface::getDayElement方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例2: render
/**
* {@inheritDoc}
*/
public function render(ElementInterface $element)
{
$dateFormat = $element->getOption('date_format');
if ($dateFormat) {
$this->setDateType($dateFormat);
}
//$name = $element->getName();
$selectHelper = $this->getSelectElementHelper();
$pattern = $this->parsePattern($element->shouldRenderDelimiters());
$daysOptions = $this->getDaysOptions($pattern['day']);
$monthsOptions = $this->getMonthsOptions($pattern['month']);
$yearOptions = $this->getYearsOptions($element->getMinYear(), $element->getMaxYear());
$dayElement = $element->getDayElement()->setValueOptions($daysOptions);
$monthElement = $element->getMonthElement()->setValueOptions($monthsOptions);
$yearElement = $element->getYearElement()->setValueOptions($yearOptions);
if ($element->shouldCreateEmptyOption()) {
$dayElement->setEmptyOption(__('Day'));
$yearElement->setEmptyOption(__('Year'));
$monthElement->setEmptyOption(__('Month'));
}
$data = array();
$data[$pattern['day']] = $selectHelper->render($dayElement);
$data[$pattern['month']] = $selectHelper->render($monthElement);
$data[$pattern['year']] = $selectHelper->render($yearElement);
$markup = '';
foreach ($pattern as $key => $value) {
// Delimiter
if (is_numeric($key)) {
$markup .= $value;
} else {
$markup .= $data[$value];
}
}
return $markup;
//return parent::render($element);
}