我想在 Joomla 3.4.8 中添加自定义表单验证。(类似于this question和this question)。我只是试图使站点(而不是后端)的现场服务器端无效。我在用着:
组件/com_comp/models/rules/sqlcheckbox.php
<?php
defined('_JEXEC') or die('Restricted access');
jimport('joomla.form.formrule');
class JFormRuleSqlCheckbox extends JFormRule
{
public function test(SimpleXMLElement $element, $value, $group = null, JRegistry $input = null, JForm $form = null)
{
return false;
}
}
组件/com_comp/models/forms/aform.xml
<?xml version="1.0" encoding="utf-8"?>
<form>
<fieldset id="aForm" name="aForm" addrulepath="components/com_comp/models/rules" addfieldpath="components/com_comp/models/fields" label="COM_DBJOBS_FORM_LABEL">
<field
id="1234567"
name="1234567"
type="text"
label="COM_COMP_LABEL"
description="COM_COMP_DESCRIPTION"
validate="sqlcheckbox"
required="true" />
</fieldset>
</form>
组件/com_comp/views/aview/tmpl/default.php
<?php
$this->form = JForm::getInstance('register', JPATH_COMPONENT.'/models/forms/aform.xml');
defined( '_JEXEC' ) or die( 'Restricted access' );
JHTML::_('behavior.formvalidator');
?>
<form id="someform" name="someform" action="" method="post" class="form-validate">
<?php foreach ($this->form->getFieldsets() as $fieldset): ?>
<div id="<?php echo $fieldset->name; ?>">
<?php foreach($this->form->getFieldset($fieldset->name) as $field): ?>
<div class="form-group">
<?php
if ( strcasecmp($field->type, 'checkbox') == 0 ) {
echo $field->input;
echo $field->label;
} else {
echo $field->label;
echo $field->input;
}
?>
</div>
<?php endforeach; ?>
</div>
<?php endforeach;?>
<div class="btn-group" id="somebutton">
<button class="arrow validate" type="submit">Submit</button>
</div>
</form>
函数 JFormRuleSqlCheckbox->test() 永远不会被调用。我究竟做错了什么?
提前致谢。