Hi @padi1111
I hope you are doing well.
It will require some custom coding.
Forminator does have a filter for it:
forminator_custom_form_submit_errors
/**
* Filter submission errors
*
* @since 1.0.2
*
* @param array $submit_errors - the submission errors
* @param int $form_id - the form id
*
* @return array $submit_errors
*/
A sample of usage can be found on https://gist.github.com/patrickfreitasdev/ec5d3d44f504e42f92891346520d3bcf
This verifies the submit and return an error to a specific field based on your code, so you can connect the DB or have a list of names in a CSV file to check while on submit.
Let us know if you have any additional questions.
Best Regards
Patrick Freitas
Ok great news !
But this function is for on submit.
What I am looking for is too check a field in live, not on submit.
Can we do that ?
Is there any documentation on these functions ?
Thx
-
This reply was modified 4 years, 10 months ago by
padi1111.
-
This reply was modified 4 years, 10 months ago by
padi1111.
-
This reply was modified 4 years, 10 months ago by
padi1111.
Hi @padi1111
What I am looking for is too check a field in live, not on submit.
In this case, you need to use JavaScript by listing the field, here is a simple example:
https://gist.github.com/patrickfreitasdev/0e90151bfce42107d574e1f5319ff148
It converts the field value to uppercase for fields that have the custom-uppercase class.
You can use a similar approach by fetching the list of users from an API and only showing the submit button if everything is good to go.
Some other codes:
Custom validation based on Regex:
https://gist.github.com/patrickfreitasdev/4187cf2f9bc8a6e3ef2c01e2436b58f4
Ajax request after user enter some data to Forminator field:
https://gist.github.com/patrickfreitasdev/d7f495e4d536daeb3efbc7067a4080cd#file-simple-mask-and-zip-br-php-L42
Is there any documentation on these functions ?
I am afraid we don’t have documentation for the hooks yet, our team is working to implement it.
Best Regards
Patrick Freitas
Nice ! That’s exactly what i’m looking for.
Only problem now is that I can get anything to execute inside $(document).on("after.load.forminator", function (e, id)… =(
I did a simple test.php page in mu-plugins that looks like that :
<?php
add_action( 'wp_footer', function(){ ?>
<script>
(function ($) {
alert("1");
$(function () {
alert("2");
$(document).on("after.load.forminator", function (e, id) {
alert("3");
jQuery('#forminator-module-2284 #forminator-field-text-1').prop("disabled", true );
});
});
})(jQuery);
</script>
<?php }, 21); ?>
I’ve got the “1” and “2” alert but can’t get to the “3”. I can’t find why
Hi @padi1111
To run on after.load.forminator your form needs to be loading from Ajax on Forminator > Behaviour > Rendering set Load from Ajax.
Let us know the result you got.
Best Regards
Patrick Freitas
I realy feel like a dumdum ^^
now it works !
Thank you very much for all your help !!!