本文整理汇总了PHP中Element::getLabel方法的典型用法代码示例。如果您正苦于以下问题:PHP Element::getLabel方法的具体用法?PHP Element::getLabel怎么用?PHP Element::getLabel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Element
的用法示例。
在下文中一共展示了Element::getLabel方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: renderLabel
protected function renderLabel(Element $element)
{
$label = $element->getLabel();
if (!empty($label)) {
echo '<label class="control-label" for="', $element->getAttribute("id"), '">';
if ($element->isRequired()) {
echo '<span class="required">* </span>';
}
echo $label, '</label>';
}
}
示例2: renderLabel
protected function renderLabel(Element $element)
{
$label = $element->getLabel();
if (!empty($label)) {
//echo '<label class="control-label" for="', $element->getAttribute("id"), '">';
echo '<div class="rmfield" for="', $element->getAttribute("id"), '"><label>';
if ($element->isRequired()) {
echo '<sup class="required">* </sup>';
}
echo $label, '</label></div>';
}
}
示例3: renderLabel
protected function renderLabel(Element $element)
{
$label = $element->getLabel();
if (empty($label)) {
$label = '';
}
echo ' <label class="text-left-xs col-xs-12 col-md-4 control-label" for="', $element->getAttribute("id"), '">';
if (!$this->noLabel && $element->isRequired()) {
echo '<span class="required">* </span>';
}
echo $label, '</label> ';
}
示例4: renderLabel
protected function renderLabel(Element $element)
{
$label = $element->getLabel();
$id = $element->getID();
$description = $element->getDescription();
if (!empty($label) || !empty($description)) {
echo '<div class="pfbc-label">';
if (!empty($label)) {
echo '<label for="', $id, '">';
if ($element->isRequired()) {
echo '<strong>*</strong> ';
}
echo $label, '</label>';
}
if (!empty($description)) {
echo '<em>', $description, '</em>';
}
echo '</div>';
}
}
示例5: html
/**
* HTML renderer
* @param Element $element
* @param string $part [all|label|field|errors]
* @param string $wrapper
* @return string
*/
protected static function html(Element &$element, $part = 'all', $wrapper = 'div')
{
$label = $element->getLabel(false);
$id = $element->getId();
//label
if ($part == 'all' || $part == 'label') {
$labelHtml = self::$templates['label'];
$labelHtml = str_replace('{{id}}', $id, $labelHtml);
$labelHtml = str_replace('{{text}}', $label, $labelHtml);
if ($part == 'label') {
return $labelHtml;
}
}
//element itself
if ($part == 'all' || $part == 'field') {
$type = $element->getType();
$fieldHtml = $element->getTemplate();
//do element specific stuff
if (is_callable("static::{$type}")) {
//elements that have specific requirements have their own methods
static::$type($element, $fieldHtml);
} else {
//the text based elements can all be handled by the text method.
//to provide custom functionality for one, simply define a static method for it
static::text($element, $fieldHtml);
}
//the hidden field type should never need the stuff below, might as well return here
if ($part == 'field' || $element->getType() == self::TYPE_HIDDEN) {
return $fieldHtml;
}
}
//errors
if ($part == 'all' || $part == 'errors') {
$errors = $element->getErrors(false);
$errorsHtml = '';
if (is_array($errors) && !empty($errors)) {
$errorsHtml = '<ul class="error-list">';
foreach ($errors as $error) {
$errorsHtml .= sprintf('<li>%s</li>', $error);
}
$errorsHtml .= '</ul>';
}
if ($part == 'errors') {
return $errorsHtml;
}
}
//all together now!
$html = '<%6$s id="%1$s_wrapper" class="%2$s-element mncedim-form-element"> %3$s %4$s %5$s </%6$s>';
if ($element->labelHidden() || in_array($element->getType(), array(self::TYPE_HIDDEN, self::TYPE_SUBMIT, self::TYPE_BUTTON))) {
$labelHtml = '';
//label not required/wanted
}
return sprintf($html, $id, str_replace('_', '-', is_object($element->form) ? $element->form->getName() : 'form'), $type == self::TYPE_CHECKBOX ? $fieldHtml : $labelHtml, $type == self::TYPE_CHECKBOX ? $labelHtml : $fieldHtml, $element->hideErrors ? '' : $errorsHtml, $wrapper);
}