Page 1 of 1
AJAX VALIDATEFORM CONTROLLER
Posted: Thu Jun 10, 2021 10:27 pm
by cahedral
Nowadays Opencart use "ajax" to validate forms.
In 2020 exists funcion in controller to validateForm() and avoid send data, but now,
how can I avoid send data to DB if exist error in form?
Thanks
Re: AJAX VALIDATEFORM CONTROLLER
Posted: Thu Jun 10, 2021 10:35 pm
by straightlight
cahedral wrote: ↑Thu Jun 10, 2021 10:27 pm
Nowadays Opencart use "ajax" to validate forms.
In 2020 exists funcion in controller to validateForm() and avoid send data, but now,
how can I avoid send data to DB if exist error in form?
Thanks
OC version. Just look in the core files for: json['error'] keys ... full of examples in there ...
Re: AJAX VALIDATEFORM CONTROLLER
Posted: Fri Jun 11, 2021 3:43 am
by cahedral
I've coded in admin\controller\localisation\language.php in save() function to validate when Save properties for example "enable/disable" language:
.... if (xxxx) then
$json['error'] = "string error"
else
"no error"
But when I set json[error] in php, ajax always store in database, but I need avoid store in database when $json['error'] is set. Now only show "tooltip error message"
How can I do it?
Re: AJAX VALIDATEFORM CONTROLLER
Posted: Fri Jun 11, 2021 6:36 am
by straightlight
cahedral wrote: ↑Fri Jun 11, 2021 3:43 am
I've coded in admin\controller\localisation\language.php in save() function to validate when Save properties for example "enable/disable" language:
.... if (xxxx) then
$json['error'] = "string error"
else
"no error"
But when I set json[error] in php, ajax always store in database, but I need avoid store in database when $json['error'] is set. Now only show "tooltip error message"
How can I do it?
You could always create a new service request in the Commercial Support section of the forum, or send me a PM directly from the forum, to have this issue solved as a custom job.
Re: AJAX VALIDATEFORM CONTROLLER
Posted: Fri Jun 11, 2021 4:39 pm
by cahedral
SOLVED.
Re: AJAX VALIDATEFORM CONTROLLER
Posted: Fri Jun 11, 2021 5:07 pm
by straightlight
Now that the issue has been solved with only one word, please add: [SOLVED] at the beginning of the subject line on your first post.