本文整理匯總了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;
}
}