Joomla 3.4 text form field custom validation not working

百般思念 提交于 2019-12-08 06:19:11

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!