本文整理汇总了PHP中HTML_QuickForm_element::export_for_template方法的典型用法代码示例。如果您正苦于以下问题:PHP HTML_QuickForm_element::export_for_template方法的具体用法?PHP HTML_QuickForm_element::export_for_template怎么用?PHP HTML_QuickForm_element::export_for_template使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HTML_QuickForm_element
的用法示例。
在下文中一共展示了HTML_QuickForm_element::export_for_template方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: mform_element
/**
* Renders an mform element from a template.
*
* @param HTML_QuickForm_element $element element
* @param bool $required if input is required field
* @param bool $advanced if input is an advanced field
* @param string $error error message to display
* @param bool $ingroup True if this element is rendered as part of a group
* @return mixed string|bool
*/
public function mform_element($element, $required, $advanced, $error, $ingroup)
{
$templatename = 'core_form/element-' . $element->getType();
if ($ingroup) {
$templatename .= "-inline";
}
try {
// We call this to generate a file not found exception if there is no template.
// We don't want to call export_for_template if there is no template.
core\output\mustache_template_finder::get_template_filepath($templatename);
if ($element instanceof templatable) {
$elementcontext = $element->export_for_template($this);
$helpbutton = '';
if (method_exists($element, 'getHelpButton')) {
$helpbutton = $element->getHelpButton();
}
$label = $element->getLabel();
if (method_exists($element, 'getText')) {
$label .= ' ' . $element->getText();
}
$context = array('element' => $elementcontext, 'label' => $label, 'required' => $required, 'advanced' => $advanced, 'helpbutton' => $helpbutton, 'error' => $error);
return $this->render_from_template($templatename, $context);
}
} catch (Exception $e) {
// No template for this element.
return false;
}
}