本文整理汇总了PHP中HTML_QuickForm_element::getName方法的典型用法代码示例。如果您正苦于以下问题:PHP HTML_QuickForm_element::getName方法的具体用法?PHP HTML_QuickForm_element::getName怎么用?PHP HTML_QuickForm_element::getName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HTML_QuickForm_element
的用法示例。
在下文中一共展示了HTML_QuickForm_element::getName方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1:
/**
* Helper used by {@link repeat_elements()}.
*
* @param int $i the index of this element.
* @param HTML_QuickForm_element $elementclone
* @param array $namecloned array of names
*/
function repeat_elements_fix_clone($i, $elementclone, &$namecloned)
{
$name = $elementclone->getName();
$namecloned[] = $name;
if (!empty($name)) {
$elementclone->setName($name . "[{$i}]");
}
if (is_a($elementclone, 'HTML_QuickForm_header')) {
$value = $elementclone->_text;
$elementclone->setValue(str_replace('{no}', $i + 1, $value));
} else {
if (is_a($elementclone, 'HTML_QuickForm_submit') || is_a($elementclone, 'HTML_QuickForm_button')) {
$elementclone->setValue(str_replace('{no}', $i + 1, $elementclone->getValue()));
} else {
$value = $elementclone->getLabel();
$elementclone->setLabel(str_replace('{no}', $i + 1, $value));
}
}
}
示例2: _prepareTemplate
/**
* Helper method for renderElement
*
* @param HTML_QuickForm_element $element
* @param bool Whether an element is required
* @param string $required Error message associated with the element
* @param string $error Label for ID
* @access private
* @see renderElement()
* @return string Html for element
*/
private function _prepareTemplate(HTML_QuickForm_element $element, $required, $error)
{
$name = $element->getName();
$label = $element->getLabel();
$labelForId = $element->getAttribute('id');
$icon = $element->getIconToHtml();
if (is_array($label)) {
$nameLabel = array_shift($label);
} else {
$nameLabel = $label;
}
$labelFor = !empty($labelForId) ? 'for="' . $labelForId . '"' : 'for="' . $element->getName() . '"';
if (isset($this->_templates[$name])) {
// Custom template
$html = str_replace('{label}', $nameLabel, $this->_templates[$name]);
} else {
$customElementTemplate = $this->getCustomElementTemplate();
if (empty($customElementTemplate)) {
if (method_exists($element, 'getTemplate')) {
$template = $element->getTemplate($this->getForm()->getLayout());
} else {
$template = $this->getForm()->getDefaultElementTemplate();
}
} else {
$template = $customElementTemplate;
}
$html = str_replace('{label}', $nameLabel, $template);
}
$html = str_replace('{label-for}', $labelFor, $html);
$html = str_replace('{icon}', $icon, $html);
if ($required) {
$html = str_replace('<!-- BEGIN required -->', '', $html);
$html = str_replace('<!-- END required -->', '', $html);
} else {
$html = preg_replace("/([ \t\n\r]*)?<!-- BEGIN required -->.*<!-- END required -->([ \t\n\r]*)?/isU", '', $html);
}
if (isset($error)) {
$html = str_replace('{error}', $error, $html);
$html = str_replace('{error_class}', 'error has-error', $html);
$html = str_replace('<!-- BEGIN error -->', '', $html);
$html = str_replace('<!-- END error -->', '', $html);
} else {
$html = str_replace('{error_class}', '', $html);
$html = preg_replace("/([ \t\n\r]*)?<!-- BEGIN error -->.*<!-- END error -->([ \t\n\r]*)?/isU", '', $html);
}
if (is_array($label)) {
foreach ($label as $key => $text) {
$key = is_int($key) ? $key + 2 : $key;
$html = str_replace("{label_{$key}}", $text, $html);
$html = str_replace("<!-- BEGIN label_{$key} -->", '', $html);
$html = str_replace("<!-- END label_{$key} -->", '', $html);
}
}
if (strpos($html, '{label_')) {
$html = preg_replace('/\\s*<!-- BEGIN label_(\\S+) -->.*<!-- END label_\\1 -->\\s*/is', '', $html);
}
return $html;
}
示例3: renderElement
/**
* Renders element
*
* @param HTML_QuickForm_element $element element
* @param bool $required if input is required field
* @param string $error error message to display
*/
function renderElement(&$element, $required, $error)
{
global $OUTPUT;
// Make sure the element has an id.
$element->_generateId();
$advanced = isset($this->_advancedElements[$element->getName()]);
$html = $OUTPUT->mform_element($element, $required, $advanced, $error, false);
$fromtemplate = !empty($html);
if (!$fromtemplate) {
// Adding stuff to place holders in template
// check if this is a group element first.
if ($this->_inGroup and !empty($this->_groupElementTemplate)) {
// So it gets substitutions for *each* element.
$html = $this->_groupElementTemplate;
} else {
if (method_exists($element, 'getElementTemplateType')) {
$html = $this->_elementTemplates[$element->getElementTemplateType()];
} else {
$html = $this->_elementTemplates['default'];
}
}
if (isset($this->_advancedElements[$element->getName()])) {
$html = str_replace(' {advanced}', ' advanced', $html);
$html = str_replace(' {aria-live}', ' aria-live="polite"', $html);
} else {
$html = str_replace(' {advanced}', '', $html);
$html = str_replace(' {aria-live}', '', $html);
}
if (isset($this->_advancedElements[$element->getName()]) || $element->getName() == 'mform_showadvanced') {
$html = str_replace('{advancedimg}', $this->_advancedHTML, $html);
} else {
$html = str_replace('{advancedimg}', '', $html);
}
$html = str_replace('{id}', 'fitem_' . $element->getAttribute('id'), $html);
$html = str_replace('{typeclass}', 'f' . $element->getType(), $html);
$html = str_replace('{type}', $element->getType(), $html);
$html = str_replace('{name}', $element->getName(), $html);
$html = str_replace('{class}', $element->getAttribute('class'), $html);
$emptylabel = '';
if ($element->getLabel() == '') {
$emptylabel = 'femptylabel';
}
$html = str_replace('{emptylabel}', $emptylabel, $html);
if (method_exists($element, 'getHelpButton')) {
$html = str_replace('{help}', $element->getHelpButton(), $html);
} else {
$html = str_replace('{help}', '', $html);
}
} else {
if ($this->_inGroup) {
$this->_groupElementTemplate = $html;
}
}
if ($this->_inGroup and !empty($this->_groupElementTemplate)) {
$this->_groupElementTemplate = $html;
} else {
if (!isset($this->_templates[$element->getName()])) {
$this->_templates[$element->getName()] = $html;
}
}
if (!$fromtemplate) {
parent::renderElement($element, $required, $error);
} else {
if (in_array($element->getName(), $this->_stopFieldsetElements) && $this->_fieldsetsOpen > 0) {
$this->_html .= $this->_closeFieldsetTemplate;
$this->_fieldsetsOpen--;
}
$this->_html .= $html;
}
}
示例4: setRequired
/**
* @param HTML_QuickForm_element $element
*/
public function setRequired(HTML_QuickForm_element $element)
{
$this->addRule($element->getName(), get_lang('ThisFieldIsRequired'), 'required');
}
示例5: renderElement
/**
* Renders a single element ready for output
* @param HTML_QuickForm_element $element Element to render
* @param boolean $required Whether this element should be marked as required
* @param string $error Error message to display for the element
* @version 2011101901
* @since 2011101901
*/
public function renderElement(&$element, $required, $error)
{
if (in_array($element->getName(), $this->_closeSlideElements) && $this->_slideOpen) {
$this->_html .= $this->_closeFieldsetTemplate;
$this->_slideOpen = false;
}
parent::renderElement($element, $required, $error);
}