Skip Navigation

[Resolved] Error when updating a custom post with a form that includes conditional fields

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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10: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/Kolkata (GMT+05:30)

This topic contains 13 replies, has 2 voices.

Last updated by Minesh 1 month, 3 weeks ago.

Assisted by: Minesh.

Author
Posts
#2751603

I created custom post types that are updated using a publication form. Everything was working fine until I was asked to make a modification, specifically to add additional fields for a specific element. I modified the publication form by adding extra fields that appear conditionally when the specific element is updated.

In that case, it works, and this element can be updated. However, the normal elements, which do not use these specific fields, can no longer be updated. I get the error: "There has been a critical error on this site."

I use debug and here is what i get :
Fatal error: Uncaught TypeError: array_filter(): Argument #1 ($array) must be of type array, string given in /home/clients/f55f0b4a215ee09cb05ae2f16b25e6ee/sites/consistoire-brumath.jlevatic2.fr/wp-content/plugins/cred-frontend-editor/application/controllers/validators/toolset_forms.php:101 Stack trace: #0 /home/clients/f55f0b4a215ee09cb05ae2f16b25e6ee/sites/consistoire-brumath.jlevatic2.fr/wp-content/plugins/cred-frontend-editor/application/controllers/validators/toolset_forms.php(101): array_filter('') #1 /home/clients/f55f0b4a215ee09cb05ae2f16b25e6ee/sites/consistoire-brumath.jlevatic2.fr/wp-content/plugins/cred-frontend-editor/application/controllers/validators/form.php(49): CRED_Validator_Toolset_Forms->validate() #2 /home/clients/f55f0b4a215ee09cb05ae2f16b25e6ee/sites/consistoire-brumath.jlevatic2.fr/wp-content/plugins/cred-frontend-editor/application/models/form/base.php(974): CRED_Validator_Form->validate() #3 /home/clients/f55f0b4a215ee09cb05ae2f16b25e6ee/sites/consistoire-brumath.jlevatic2.fr/wp-content/plugins/cred-frontend-editor/application/models/form/base.php(423): CRED_Form_Base->validate_form(NULL) #4 /home/clients/f55f0b4a215ee09cb05ae2f16b25e6ee/sites/consistoire-brumath.jlevatic2.fr/wp-content/plugins/cred-frontend-editor/application/controllers/form_builder_base.php(42): CRED_Form_Base->print_form() #5 /home/clients/f55f0b4a215ee09cb05ae2f16b25e6ee/sites/consistoire-brumath.jlevatic2.fr/wp-content/plugins/cred-frontend-editor/library/toolset/cred/embedded/classes/CRED_Helper.php(1799): CRED_Form_Builder_Base->get_form(1603, '') #6 /home/clients/f55f0b4a215ee09cb05ae2f16b25e6ee/sites/consistoire-brumath.jlevatic2.fr/wp-content/plugins/cred-frontend-editor/library/toolset/cred/embedded/classes/CRED_Helper.php(2398): CRED_Helper::cred_form('modifier-une-pa...', '') #7 /home/clients/f55f0b4a215ee09cb05ae2f16b25e6ee/sites/consistoire-brumath.jlevatic2.fr/wp-includes/shortcodes.php(434): CRED_Helper::credFormShortcode(Array, '', 'cred-form') #8 [internal function]: do_shortcode_tag(Array) #9 /home/clients/f55f0b4a215ee09cb05ae2f16b25e6ee/sites/consistoire-brumath.jlevatic2.fr/wp-includes/shortcodes.php(273): preg_replace_callback('/\\[(\\[?)(cred\\-...', 'do_shortcode_ta...', '\n<div class="wp...') #10 /home/clients/f55f0b4a215ee09cb05ae2f16b25e6ee/sites/consistoire-brumath.jlevatic2.fr/wp-includes/class-wp-hook.php(324): do_shortcode('\n<div class="wp...') #11 /home/clients/f55f0b4a215ee09cb05ae2f16b25e6ee/sites/consistoire-brumath.jlevatic2.fr/wp-includes/plugin.php(205): WP_Hook->apply_filters('\n<div class="wp...', Array) #12 /home/clients/f55f0b4a215ee09cb05ae2f16b25e6ee/sites/consistoire-brumath.jlevatic2.fr/wp-content/plugins/elementor-pro/modules/posts/skins/skin-content-base.php(281): apply_filters('the_content', '') #13 /home/clients/f55f0b4a215ee09cb05ae2f16b25e6ee/sites/consistoire-brumath.jlevatic2.fr/wp-content/plugins/elementor-pro/modules/theme-builder/widgets/post-content.php(111): ElementorPro\Modules\ThemeBuilder\Widgets\Post_Content->render_post_content(false, false) #14 /home/clients/f55f0b4a215ee09cb05ae2f16b25e6ee/sites/consistoire-brumath.jlevatic2.fr/wp-content/plugins/elementor/includes/base/controls-stack.php(2325): ElementorPro\Modules\ThemeBuilder\Widgets\Post_Content->render() #15 /home/clients/f55f0b4a215ee09cb05ae2f16b25e6ee/sites/consistoire-brumath.jlevatic2.fr/wp-content/plugins/elementor/includes/base/widget-base.php(635): Elementor\Controls_Stack->render_by_mode() #16 /home/clients/f55f0b4a215ee09cb05ae2f16b25e6ee/sites/consistoire-brumath.jlevatic2.fr/wp-content/plugins/elementor/includes/base/widget-base.php(776): Elementor\Widget_Base->render_content() #17 /home/clients/f55f0b4a215ee09cb05ae2f16b25e6ee/sites/consistoire-brumath.jlevatic2.fr/wp-content/plugins/elementor/includes/base/element-base.php(483): Elementor\Widget_Base->print_content() #18 /home/clients/f55f0b4a215ee09cb05ae2f16b25e6ee/sites/consistoire-brumath.jlevatic2.fr/wp-content/plugins/elementor/includes/base/element-base.php(1442): Elementor\Element_Base->print_element() #19 /home/clients/f55f0b4a215ee09cb05ae2f16b25e6ee/sites/consistoire-brumath.jlevatic2.fr/wp-content/plugins/elementor/includes/base/element-base.php(483): Elementor\Element_Base->print_content() #20 /home/clients/f55f0b4a215ee09cb05ae2f16b25e6ee/sites/consistoire-brumath.jlevatic2.fr/wp-content/plugins/elementor/core/base/document.php(1875): Elementor\Element_Base->print_element() #21 /home/clients/f55f0b4a215ee09cb05ae2f16b25e6ee/sites/consistoire-brumath.jlevatic2.fr/wp-content/plugins/elementor/core/base/document.php(1800): Elementor\Core\Base\Document->do_print_elements(Array) #22 /home/clients/f55f0b4a215ee09cb05ae2f16b25e6ee/sites/consistoire-brumath.jlevatic2.fr/wp-content/plugins/elementor-pro/modules/theme-builder/documents/theme-document.php(412): Elementor\Core\Base\Document->print_elements(Array) #23 /home/clients/f55f0b4a215ee09cb05ae2f16b25e6ee/sites/consistoire-brumath.jlevatic2.fr/wp-content/plugins/elementor/includes/frontend.php(1200): ElementorPro\Modules\ThemeBuilder\Documents\Theme_Document->print_elements_with_wrapper(Array) #24 /home/clients/f55f0b4a215ee09cb05ae2f16b25e6ee/sites/consistoire-brumath.jlevatic2.fr/wp-content/plugins/elementor/core/base/document.php(1249): Elementor\Frontend->get_builder_content(1059, false) #25 /home/clients/f55f0b4a215ee09cb05ae2f16b25e6ee/sites/consistoire-brumath.jlevatic2.fr/wp-content/plugins/elementor/modules/library/documents/library-document.php(76): Elementor\Core\Base\Document->get_content(false) #26 /home/clients/f55f0b4a215ee09cb05ae2f16b25e6ee/sites/consistoire-brumath.jlevatic2.fr/wp-content/plugins/elementor-pro/modules/theme-builder/documents/theme-document.php(158): Elementor\Modules\Library\Documents\Library_Document->get_content(false) #27 /home/clients/f55f0b4a215ee09cb05ae2f16b25e6ee/sites/consistoire-brumath.jlevatic2.fr/wp-content/plugins/elementor-pro/modules/theme-builder/documents/theme-document.php(173): ElementorPro\Modules\ThemeBuilder\Documents\Theme_Document->get_content() #28 /home/clients/f55f0b4a215ee09cb05ae2f16b25e6ee/sites/consistoire-brumath.jlevatic2.fr/wp-content/plugins/elementor-pro/modules/theme-builder/documents/single-base.php(93): ElementorPro\Modules\ThemeBuilder\Documents\Theme_Document->print_content() #29 /home/clients/f55f0b4a215ee09cb05ae2f16b25e6ee/sites/consistoire-brumath.jlevatic2.fr/wp-content/plugins/elementor-pro/modules/theme-builder/classes/locations-manager.php(370): ElementorPro\Modules\ThemeBuilder\Documents\Single_Base->print_content() #30 /home/clients/f55f0b4a215ee09cb05ae2f16b25e6ee/sites/consistoire-brumath.jlevatic2.fr/wp-content/plugins/elementor-pro/modules/theme-builder/api.php(13): ElementorPro\Modules\ThemeBuilder\Classes\Locations_Manager->do_location('single') #31 /home/clients/f55f0b4a215ee09cb05ae2f16b25e6ee/sites/consistoire-brumath.jlevatic2.fr/wp-content/themes/hello-elementor/index.php(20): elementor_theme_do_location('single') #32 /home/clients/f55f0b4a215ee09cb05ae2f16b25e6ee/sites/consistoire-brumath.jlevatic2.fr/wp-includes/template-loader.php(106): include('/home/clients/f...') #33 /home/clients/f55f0b4a215ee09cb05ae2f16b25e6ee/sites/consistoire-brumath.jlevatic2.fr/wp-blog-header.php(19): require_once('/home/clients/f...') #34 /home/clients/f55f0b4a215ee09cb05ae2f16b25e6ee/sites/consistoire-brumath.jlevatic2.fr/index.php(17): require('/home/clients/f...') #35 {main} thrown in /home/clients/f55f0b4a215ee09cb05ae2f16b25e6ee/sites/consistoire-brumath.jlevatic2.fr/wp-content/plugins/cred-frontend-editor/application/controllers/validators/toolset_forms.php on line 101

#2751640

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

This is strange.

Can you please share bit more details what you updated and what fields you would like to have required fields and what steps I should follow in order to reproduce the issue with problem URL where you added the form.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.

#2754663

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Thank you for sharing admin access details but unfortunately its not working at this end.

Can you please send me working admin access details.

Also, Can you please confirm on what post/page you added the form the “Ajouter une Paroisse (ID: 1602)”?

If it requires to access the form as frontend user, Can you please send me frontend user access details as well.

I have set the next reply to private which means only you and I have access to it.

#2754959

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Sorry but the links you shared:
- hidden link
- hidden link

I see a form with above links but the form displayed with above links is the form ID 1603.

With your previous reply you shared that the you done modifications to the form the “Ajouter une Paroisse (ID: 1602)”.

Can you please share exact steps that I've to follow to see the issue. Like problem URL where I can see the form as well as exact steps I will have to follow to see the issue.

#2755025

In fact, the form with the id 1603 is the one that's causing me problems, because it's the one that's going to be used to update the elements. the one with the ID 1602, allows elements to be created, but isn't used in the front, just in the back and it works.

#2755088

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Is this form displaying all fields correctly now?
=> hidden link

#2755284

No, the categories shouldn't be there because I don't use them, nor the labels, nor the title, nor the Parish Content. The rest is fine. However, it's still not possible to update without errors....

However, conditional fields are not displayed because they do not correspond to the element displayed, which is fine.

#2755292

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Can you please just remove the unwanted fields you do not want from the form and save the form:
- hidden link

And tell me what steps I should follow to see the issue also what conditional display you added and to what field? Where I can see you added the conditional display?

#2755325

It's done, when you go to hidden link and click on the big green "send" button to update the custom post, you get an error, that's the problem....

#2755348

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Where you added the conditional fields - I do not see any conditional display added to the form.
- hidden link

I also see you are using WP Rocket plugin - Please check the following Doc and later on try to exclude the mention files:
- https://toolset.com/faq/how-to-use-optimization-plugins-with-toolset/

#2756296
Capture d’écran 2024-09-25 085755.jpg

I have just unpacked WP Rocket and all the other plugins except elementor pro, and the problem persists. Concerning the conditional display, I have selected it directly in the custom fields of the group "Infos paroisse"

#2756338

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Ok - I see you have added custom CSS code to hide those fields on the form that you do not wish to display.

Can you first remove all those custom CSS code so that first I can see normal form.

You still want to make sure that those fields only display with the same condition you setup in the backend:
- https://toolset.com/wp-content/uploads/2024/09/2756296-Capture_d_cran_2024_09_25_085755.jpg
===> is that correct? if yes:

Can you please first remove all those custom CSS code that you added so all fields displayed on the form.

And then what if you try to use the Toolset form's conditional display:
- https://toolset.com/course-lesson/conditional-display-for-form-inputs/

#2756374

The custom CSS code wasn't used to hide fields on the form, but to design it. However, I've removed the conditional display from the custom fields in the field group and put one in place directly in the form and it seems to work. I'm still going to test it more thoroughly before confirming, but it looks good 😉

#2756412

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

That is great. I hope using conditional for forms will help you to fix the issue.

#2763362

Thanks it worked well !!!