本文整理汇总了PHP中HTML_QuickForm_element::getAttribute方法的典型用法代码示例。如果您正苦于以下问题:PHP HTML_QuickForm_element::getAttribute方法的具体用法?PHP HTML_QuickForm_element::getAttribute怎么用?PHP HTML_QuickForm_element::getAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HTML_QuickForm_element
的用法示例。
在下文中一共展示了HTML_QuickForm_element::getAttribute方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _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;
}
示例2: guess_element_id
/**
* Returns the CSS id attribute that will be assigned by moodleform later to this element
* @param stdClass $item
* @param HTML_QuickForm_element $element
*/
protected function guess_element_id($item, $element)
{
if (!($id = $element->getAttribute('id'))) {
$attributes = $element->getAttributes();
$id = $attributes['id'] = 'feedback_item_' . $item->id;
$element->setAttributes($attributes);
}
if ($element->getType() === 'group') {
return 'fgroup_' . $id;
}
return 'fitem_' . $id;
}
示例3: addOptionsEditLink
/**
* @param array $el
* @param HTML_QuickForm_element $field
*/
public function addOptionsEditLink(&$el, $field)
{
if (CRM_Core_Permission::check('administer CiviCRM')) {
// NOTE: $path is used on the client-side to know which option lists need rebuilding,
// that's why we need that bit of data both in the link and in the form element
$path = $field->getAttribute('data-option-edit-path');
// NOTE: If we ever needed to support arguments in this link other than reset=1 we could split $path here if it contains a ?
$url = CRM_Utils_System::url($path, 'reset=1');
$el['html'] .= ' <a href="' . $url . '" class="crm-option-edit-link medium-popup crm-hover-button" target="_blank" title="' . ts('Edit Options') . '" data-option-edit-path="' . $path . '"><span class="icon ui-icon-wrench"></span></a>';
}
}
示例4: addOptionsEditLink
/**
* @param array $el
* @param HTML_QuickForm_element $field
*/
function addOptionsEditLink(&$el, $field)
{
if (CRM_Core_Permission::check('administer CiviCRM')) {
$el['html'] .= ' <a href="#" class="crm-edit-optionvalue-link crm-hover-button" title="' . ts('Edit Options') . '" data-option-group-url="' . $field->getAttribute('data-option-group-url') . '"><span class="icon edit-icon"></span></a>';
}
}