本文整理汇总了PHP中XoopsThemeForm::AddElement方法的典型用法代码示例。如果您正苦于以下问题:PHP XoopsThemeForm::AddElement方法的具体用法?PHP XoopsThemeForm::AddElement怎么用?PHP XoopsThemeForm::AddElement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XoopsThemeForm
的用法示例。
在下文中一共展示了XoopsThemeForm::AddElement方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addElement
/**
* Add an element to the form
*
* @param object &$formElement reference to a {@link XoopsFormElement}
* @param bool $required is this a "required" element?
*/
function addElement(&$formElement, $key = false, $var = false, $required = 'notset')
{
if ($key) {
if ($this->targetObject->vars[$key]['readonly']) {
$formElement->setExtra('disabled="disabled"');
$formElement->setName($key . '-readonly');
// Since this element is disable, we still want to pass it's value in the form
$hidden = new XoopsFormHidden($key, $this->targetObject->vars[$key]['value']);
$this->addElement($hidden);
}
$formElement->setDescription($var['form_dsc']);
if (isset($this->targetObject->controls[$key]['onSelect'])) {
$hidden = new XoopsFormHidden('changedField', false);
$this->addElement($hidden);
$otherExtra = isset($var['form_extra']) ? $var['form_extra'] : '';
$onchangedString = "this.form.elements.changedField.value='{$key}'; this.form.elements.op.value='changedField'; submit()";
$formElement->setExtra('onchange="' . $onchangedString . '"' . ' ' . $otherExtra);
} else {
if (isset($var['form_extra'])) {
$formElement->setExtra($var['form_extra']);
}
}
$controls = $this->targetObject->controls;
if (isset($controls[$key]['js'])) {
$formElement->customValidationCode[] = $controls[$key]['js'];
}
parent::AddElement($formElement, $required == 'notset' ? $var['required'] : $required);
} else {
parent::AddElement($formElement, $required == 'notset' ? false : true);
}
unset($formElement);
}