Muito obrigado andopes for your help.
After many try and inspections with firebug and firephp (thanks to this two awesome addons), I finally found how to use the function addToValidateComparison(). But it's still buggy. Here is how to use it:
In Accounts/EditVIew.php, after: $javascript = new javascript(); and the calls to functions of the javascript's object I add:
PHP Code:
require_once('modules/Users/User.php');
$check_role = new User();
if ($check_role->check_role_membership('Other', $user_id = '')) {
//addToValidateComparison($field, $type, $displayName, $required, $prefix='',$compareTo)
$javascript->addToValidateComparison('city_c', 'varchar', 'The city must be Boston', 'true', $prefix='','city_ref_boston');
}
So, true must be between ' ', and the $compareTo must refer to an other field for the comparison ... why not ! So I refer to this field with 'city_ref_boston' and added an empty input field in my form in Accounts/EditView.html:
HTML Code:
<td width="30%" valign="top" class="dataField">
<span sugar='slot124b'>
<input type='hidden' name='city_ref_boston' id='city_ref_boston' size='35' maxlength='50' value='Boston'>
</span sugar='slot'>
</td> In this case, if the user enter each time a value else than "Boston", the error message will appear each time and the form won't be save (what I expect, so that's fine in this case).
But, if the user let the field that need to be checked (city_c) empty, he would have the error message bellow the field. If he try a 2nd time to save the form with an empty value or a value else than "Boston" the form will be saved !!! What I didn't expect it will do.
Any idea how to resolve that ?
Thanks a lot for suggestions.
Damien
Bookmarks