Php validation

mmitechnic

New Member
Hello all, i am having a problem to understand how to use php validation in Fabrik. I saw some examples here and there in Google and forum but nothing to explain what to do.

In case we have the field imo and we would like to add the following validation

public static final boolean isImoValid(String imo) {
if (imo == null || imo.length() != 7) {
return false;
}
char[] a = imo.toCharArray();
int sum = 0;
for(int i = 0; i < 6; i++) {
sum += (a-48)*(a.length-i);
}
return sum % 10 == a[6]-48;
}
How is it possible to achieve this.
Or for example if we would like to say that the imo field would be equal to 7 digits how the syntax will be?
Thanks in advance
 
Run any php code you need (php code, no function, no javascript).
Return true if validation passed, false if failed.
 
- Your code is no valid php (vars must start with $)
- element data is in $data

so something like
if (is_numeric($data))...

For testing you should set Joomla error reporting to max.
 
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top