Skip to content

CCF is not accounting for multiple defaults #73

Description

@evolluti0n

What Was The Original Issue?
Hey guys, just wanted to give a heads up on a bug I found on the Connected Caldera Forms plugin. After you guys introduced the ability to set multiple defaults for a radio / checkbox / select field, if I use that along with CCF, after I submit a form, I might get this error: "Warning: strpos() expects parameter 1 to be string, array given in (...)wp-content\plugins\cf-connected-forms\includes\calcdefaults.php on line 87". This happens because CCF is not accounting for multiple defaults. But I think it's an easy fix. Here's how I fixed (an updated version of the function responsible for the bug):

/**
* Check if a value is a '{prev:}' magic tag
*
* @since 1.2.2
*
* @param string $test
*
* @return bool
*/
protected static function is_prev_magic( $test ){
if( is_array( $test ) ) {
foreach( $test as $test_value ) {
if( 0 === strpos( $test_value, '{prev:' ) ) {
return true;
}
}
return false;
} else {
return 0 === strpos( $test, '{prev:' );
}
}

Hope this helps to get this bug fixed!

What add-on(s) Does This Related To?
Connected Caldera Forms plugin version 1.2.2

What version of PHP, Caldera Forms and WordPress
WordPress Version
4.9.8
PHP Version
5.6
Caldera Forms Version
1.7.4
Add-on Version
1.2.2

What Are The Relevant Errors?
Warning: strpos() expects parameter 1 to be string, array given in (...)\wp-content\plugins\cf-connected-forms\includes\calcdefaults.php on line 87

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions