Skip Navigation

[Resolved] Multiselect generic field box generates PHP error…. trim() expects

This thread is resolved. Here is a description of the problem and solution.

Problem:

Generic "multiselect" field in Toolset form outputs some PHP warning message, see details here:

https://toolset.com/forums/topic/multiselect-generic-field-box-generates-php-error-trim-expects/#post-1179488

Solution:

This issue will be fixed in the next release of the Toolset Forms plugin, currently, you can try the patch file in errata here:

https://toolset.com/errata/php-error-when-using-generic-multiselect-form-fields/

Relevant Documentation:

This support ticket is created 5 years, 10 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 5 replies, has 2 voices.

Last updated by Luo Yang 5 years, 10 months ago.

Assisted by: Luo Yang.

Author
Posts
#1179488

hidden link

A form that has been working for ages has broken recently. I'm using Version 2.2.1.1

Inside a form is the following generic field


[cred_generic_field field='individual_recipients' type='multiselect' ]
{
"required":0,
"validate_format":1,
"default":["0"],
"options":[json-users-list]
}
[/cred_generic_field]

The shortcode used for the options generates a list of users.

The page has suddenly started showing the PHP error
Warning: trim() expects parameter 1 to be string, array given in /home/sites/schoolofanaesthesia.co.uk/public_html/wp-content/plugins/types/vendor/toolset/toolset-common/toolset-forms/classes/class.eforms.php on line 1085

many times on the page.

If I change the code to a select box, rather than a multiselect, the error goes away.

[cred_generic_field field='individual_recipients' type='select' ]

the error message is not shown.

However I do need a multiselect box .

For your reference, the source code for the shortcode is

/*  Get all Users, in JSON format. Used to fill Select Boxes */
 add_shortcode( 'json-users-list', 'wpmania_json_users_list' );
 function wpmania_json_users_list( $atts ) {
    $args = array(  'fields' => array('ID','display_name'),
                     'exclude'      => array(82), 
                    'orderby' => 'display_name');
    $users = get_users( $args );
    $json = json_encode($users);
    $json = str_replace('"ID"','"value"',$json);
    $json = str_replace('"display_name"','"label"',$json);
   
    $json=str_replace("[","[{\"value\":\"0\",\"label\":\"==== SELECT USER ====\"},",$json);
   

    return $json;
}


#1179765

Hello,

Thanks for the feedback, I can duplicate the same problem in my localhost, it should be a bug, so I have escalated it to our 2nd tier supporters, will update here if there is anything news.

#1179960

This is escalated to our developers as a BUG, in to-do list of Toolset form plugin version 2.2.2, but currently there isn't any fix/workaround for it. See the errata:
https://toolset.com/errata/php-error-when-using-generic-multiselect-form-fields/

#1181315

Here is the update:

This issue will be fixed in the next release of the Toolset Forms plugin, currently, you can try the patch file in errata here:
https://toolset.com/errata/php-error-when-using-generic-multiselect-form-fields/

Please test it and feedback if it is fixed. thanks

#1181512

My issue is resolved now. Thank you!

#1181787

You are welcome