<div dir="ltr">Hi Alan,<div><br></div><div><span style="font-size:13px"><i>Suppose I want to apply this validation check to all UI Type 11 (phone number) fields for all/any modules... How do I do that?</i></span><br></div><div><span style="font-size:13px"><i><br></i></span></div><div><span style="font-size:13px">This can be achieved at Field model level, like you already know if for all module in Vtiger_Field_Model and if for few module then particular module Field_Model level in getValidator api(), by checking uitype of field instead of fieldname.</span></div><div><span style="font-size:13px"><br></span></div><div><span style="font-size:13px"><i>Secondly, suppose I want to apply a single validation check to *any* editable field on a module record only if the record is *not* a new one?</i></span><span style="font-size:13px"><br></span></div><div><span style="font-size:13px"><i><br></i></span></div><div><span style="font-size:13px">If you want apply validation on a record only if it's not new, then we need to check on mode of record whether it is edit mode and apply validation.</span></div><div><span style="font-size:13px"><br></span></div><div><span style="font-size:13px">Hope this might add some value for discussion.</span></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Feb 20, 2015 at 10:31 PM, Alan Lord <span dir="ltr"><<a href="mailto:alanslists@gmail.com" target="_blank">alanslists@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Following on from the earlier discussion on the new vtiger validation engine, I see how I can add a new custom validation to a specific field; e.g.<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
class Leads_Field_Model extends Vtiger_Field_Model {<br>
<br>
        function getValidator() {<br>
                $validator = parent::getValidator();<br>
                $fieldName = $this->getName();<br>
                switch($fieldName) {<br>
                        case 'phone' : $funcName = array('name'=>'<u></u>GlobalPhoneCheck');<br>
                                                    array_push($validator, $funcName);<br>
                                                        break;                  <br>
                }<br>
                return $validator;<br>
        }<br>
}<br>
</blockquote>
<br>
In the above case I'm adding my validation function "GlobalPhoneCheck" to the field called "phone" in the Lead module.<br>
<br>
Suppose I want to apply this validation check to all UI Type 11 (phone number) fields for all/any modules... How do I do that?<br>
<br>
Secondly, suppose I want to apply a single validation check to *any* editable field on a module record only if the record is *not* a new one?<br>
<br>
Cheers<br>
<br>
Al<br>
<br>
<br>
<br>
______________________________<u></u>_________________<br>
<a href="http://www.vtiger.com/" target="_blank">http://www.vtiger.com/</a><br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr">With<br>Best Regards<br>Uma.S<br><div>Vtiger Team</div></div></div>
</div>