Filter Processor would not get $from data
-
Hey people,
I could make an action processor work. But it just won’t work for a pre-process filter in order to validate a field on my form.
I get into the function however I cannot get the field data. This is my PHP: `<?
//** checks the lenght of the field VIN – must be exactly 17 characters long **//
function check_vin( $vin ) {
if ( strlen( $vin ) == 17 ) {
return true;
}
else {
return false;
}
}//** call from the run action processor filter pre processing **//
add_filter(‘caldera_forms_get_form_processors’, ‘slug_custom_validation_register’);
function slug_custom_validation_register($processors){$processors[‘slug_custom_validation’] = array(
“name” => ‘Custom Validation’,
“pre_processor” => ‘slug_custom_validation_do_validation’,
“cf_ver” => ‘1.2.4’
);
return $processors;
}//pre-process callback
function slug_custom_validation_do_validation( $config, $form ) {$value_to_check = ”;
$data = array();//MAKE SURE TO SET FIELD ID TO YOUR FIELD ID
$value_to_check = Caldera_Forms::get_field_data( ‘fld_5188483’, $form );
// just for testing I write the value into a text file – which works – but $value_to_check is always empty
$text = “VIN = ” . $value_to_check . “\n”;
file_put_contents( “caldera-test.txt”, $text, FILE_APPEND );$is_valid = true;
$file_text = ” im DO: ” . $value_to_check . ” \n”;
file_put_contents( “caldera-test.txt”, $file_text , FILE_APPEND );
//Do your thing to check if is valid and make $is_valid false if not
if( function_exists( ‘check_vin’ ) ) {
$is_valid = check_vin( $value_to_check );
}//return an error if not valid, else don’t do anything
if( ! $is_valid ) {
return array(
‘type’ => ‘error’,
‘note’ => __( ‘A valid VIN must be 17 charaters long – please check the VIN of your car.’, ‘my-text-domain’ )
);
}
}
`More or less I took this code from Caldera Forms Support
In the Caldero Front end I cal the function as a filter processor by slug_custom_validation_do_validation
The site of concern is: mycarbio.livedemo.click
Any idea what I’m doin’ wrong?
Thank you very much for any help
Chris
- The topic ‘Filter Processor would not get $from data’ is closed to new replies.