本文整理汇总了PHP中Zend\Form\ElementInterface::isSummaryEmpty方法的典型用法代码示例。如果您正苦于以下问题:PHP ElementInterface::isSummaryEmpty方法的具体用法?PHP ElementInterface::isSummaryEmpty怎么用?PHP ElementInterface::isSummaryEmpty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Form\ElementInterface
的用法示例。
在下文中一共展示了ElementInterface::isSummaryEmpty方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: renderSummaryElement
/**
* Helper function to recurse into form elements when rendering summary.
*
* @param ElementInterface $element
* @return string
*/
protected function renderSummaryElement(ElementInterface $element)
{
if ($element instanceof Hidden || false === $element->getOption('render_summary')) {
return '';
}
if ($element instanceof ViewPartialProviderInterface) {
$partial = $element->getViewPartial();
$summaryPartial = $partial . '.summary';
$partialParams = array('element' => $element);
if (!$this->getView()->resolver($summaryPartial)) {
$summaryPartial = $partial;
$partialParams['renderSummary'] = true;
}
return $this->getView()->partial($summaryPartial, $partialParams);
}
if ($element instanceof EmptySummaryAwareInterface && $element->isSummaryEmpty()) {
$emptySummaryNotice = $this->getTranslator()->translate($element->getEmptySummaryNotice(), $this->getTranslatorTextDomain());
$markup = sprintf('<div id="%s-empty-alert" class="empty-summary-notice alert alert-info"><p>%s</p></div>', $element->getAttribute('id'), $emptySummaryNotice);
return $markup;
}
$label = $element->getLabel();
$markup = '';
if ($element instanceof FieldsetInterface) {
if (!$element instanceof FormInterface && $label) {
$markup .= '<h4>' . $label . '</h4>';
}
foreach ($element as $el) {
$markup .= $this->renderSummaryElement($el);
}
return $markup;
}
$elementValue = $element instanceof \Zend\Form\Element\Textarea ? nl2br($element->getValue()) : $element->getValue();
$markup .= '<div class="row">';
$col = 12;
if ($label) {
$markup .= '<div class="col-md-3"><strong>' . $label . '</strong></div>';
$col = 9;
}
$markup .= '<div class="col-md-' . $col . '">' . $elementValue . '</div>' . '</div>';
return $markup;
}
示例2: renderSummaryElement
/**
* Helper function to recurse into form elements when rendering summary.
*
* @param ElementInterface $element
* @return string
*/
protected function renderSummaryElement(ElementInterface $element)
{
if ($element instanceof Hidden || false === $element->getOption('render_summary')) {
return '';
}
if ($element instanceof ViewPartialProviderInterface) {
$renderer = $this->getView();
/* @var $renderer \Zend\View\Renderer\PhpRenderer */
$origPartial = $element->getViewPartial();
$partial = "{$origPartial}.view";
$partialParams = array('element' => $element);
if (!$renderer->resolver($partial)) {
$partial = $origPartial;
$partialParams['renderSummary'] = true;
}
return $renderer->partial($partial, $partialParams);
}
if ($element instanceof EmptySummaryAwareInterface && $element->isSummaryEmpty()) {
/* @var $element EmptySummaryAwareInterface|ElementInterface */
$emptySummaryNotice = $this->getTranslator()->translate($element->getEmptySummaryNotice(), $this->getTranslatorTextDomain());
$markup = sprintf('<div id="%s-empty-alert" class="empty-summary-notice alert alert-info"><p>%s</p></div>', $element->getAttribute('id'), $emptySummaryNotice);
return $markup;
}
$label = $this->getTranslator()->translate($element->getLabel());
$markup = '';
if ($element instanceof FieldsetInterface) {
if (!$element instanceof FormInterface && $label) {
$markup .= '<h4>' . $label . '</h4>';
}
foreach ($element as $el) {
$markup .= $this->renderSummaryElement($el);
}
return $markup;
}
$elementValue = $element instanceof \Zend\Form\Element\Textarea ? nl2br($element->getValue()) : $element->getValue();
if ('' != $elementValue && $element instanceof \Zend\Form\Element\Select) {
$options = $element->getValueOptions();
$translator = $this->getTranslator();
if (true == $element->getAttribute('multiple')) {
$multiOptions = [];
foreach ($elementValue as $optionKey) {
if (isset($options[$optionKey])) {
$multiOptions['__general__'][] = $translator->translate($options[$optionKey]);
continue;
}
foreach ($options as $optKey => $optVal) {
if (!is_array($optVal) || !array_key_exists($optionKey, $optVal['options'])) {
continue;
}
$optGroupLabel = isset($optVal['label']) ? $translator->translate($optVal['label']) : $optKey;
$multiOptions[$optGroupLabel][] = $translator->translate($optVal['options'][$optionKey]);
}
}
$elementValue = [];
foreach ($multiOptions as $optGroupLabel => $vals) {
$elementValue[] = "<b>{$optGroupLabel}</b><br>" . join(', ', $vals);
}
$elementValue = join('<br>', $elementValue) . '<br>';
} else {
$elementValue = $translator->translate($options[$elementValue]);
}
}
if ('' != $elementValue && $element instanceof \Zend\Form\Element\File) {
return '';
}
$markup .= '<div class="row">';
$col = 12;
if ($label) {
$markup .= '<div class="col-md-3 yk-label"><label>' . $label . '</label></div>';
$col = 9;
}
$markup .= '<div class="col-md-' . $col . '">' . $elementValue . '</div>' . '</div>';
return $markup;
}