Can validation function change the value?

I have successfully created a custom validation function, but am discovering that it is (correctly) failing things like leading or trailing spaces which I don't want in the database. Is the validation function able to modify the current value to make it fit rather than rejecting it, if possible?

You are using DaDaBIK version 10.1-Manarola enterprise, installed on 17-03-2020

You are runnning the last release of DaDaBIK

PHP Version: 7.2.24-0ubuntu0.18.04.3

mysql version: 5.7.29-0ubuntu0.18.04.1

Web server: Apache/2.4.29 (Ubuntu)

Client: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:74.0) Gecko/20100101 Firefox/74.0
 

eugenio

Administrator
Staff member
No, it is not possible using validation functions but there are a couple of other ways:

1) before insert hooks: you can modify the form input values, according to some custom logic, before the actual insertion
2) JS event functions: for example, if you want to automatically make uppercase the content of a field when the user leaves the form field (see form configurator)

Being server-side, 1) is more robust and secure.

Best,
 
Top