问题
I'm try to add my server-side validation for text form field in Joomla 3.4. When I submit form with any empty field message that field is empty appear, but when it not empty submit is working and ignoring email and my own validation. Also email validation work only when I set type="email" but not for type="text". This is what I have:
\components\com_my\models\rules\myrule.xml
<?php
defined('_JEXEC') or die;
jimport('joomla.form.formrule');
class JFormRuleMyrule extends JFormRule
{
public function test(SimpleXMLElement $element, $value, $group = null, JRegistry $input = null, JForm $form = null)
{
return false;
}
}
\components\com_my\models\forms\form.xml
<form>
<fieldset name="default" addrulepath="/components/com_my/models/rules" label="My form">
<field
name="user"
type="text"
label="Label"
message="Message"
required="true"
size="10"
maxsize="10"
validate="myrule"
/>
<field
name="mail"
type="text"
label="Label"
message="Message"
required="true"
validate="email"
/>
</fieldset>
</form>
Will be glad to get any help about this! Thank you!
来源:https://stackoverflow.com/questions/33689187/joomla-3-4-text-form-field-custom-validation-not-working