Skip Navigation

[Resolved] CRED edit form throws an error on Submit

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

Problem:
The user was having errors when submitting a cred form.

Solution:
It turns out that the issue comes from some erroneous conditions on some date fields. After recreating the conditions the issue has dissappeared.

This support ticket is created 4 years, 1 month 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: Africa/Casablanca (GMT+01:00)

Author
Posts
#1843849

I am trying to use a CRED edit form to edit a WooCommerce product that has an associated Types Custom Fields Group

Link to a page where the issue can be seen: hidden link

After editing one of the CRED form fields, I expected to see the updated Product post.

Instead, I got the following error message:

Fatal error: Uncaught TypeError: DateTime::__construct() expects parameter 1 to be string, array given in /var/www/html/site/wp-content/plugins/types/vendor/toolset/toolset-common/toolset-forms/classes/class.date.php:522 Stack trace:
#0 /var/www/html/site/wp-content/plugins/types/vendor/toolset/toolset-common/toolset-forms/classes/class.date.php(522): DateTime->__construct(Array)
#1 /var/www/html/site/wp-content/plugins/types/vendor/toolset/toolset-common/toolset-forms/classes/class.date.php(483): WPToolset_Field_Date::strtotime(Array)
#2 /var/www/html/site/wp-includes/class-wp-hook.php(289): WPToolset_Field_Date::filterConditionalValuePhp(Array, 'date')
#3 /var/www/html/site/wp-includes/plugin.php(206): WP_Hook->apply_filters(Array, Array)
#4 /var/www/html/site/wp-content/plugins/types/vendor/toolset/toolset-common/toolset-forms/classes/class.conditional.php(355): apply_filters('wptoolset_condi...', Array, 'date', 'wpcf-recording-...')
#5 /var/www/html/site/wp-content/plugins/types/vendor/toolset/toolset-common/toolset-f in /var/www/html/site/wp-content/plugins/types/vendor/toolset/toolset-common/toolset-forms/classes/class.date.php on line 522

This site is a BlogVault staging site so you'll need the following info to view the site and before using the wp-admin info provided below: Username = blogvault Password = 73b1460a

#1844355

Hello and thank you for contacting the Toolset support.

I logged into the website and was able to reproduce the issue. Before we can analyze this further, we'll need to check if it is not also triggered by a third party component(theme or plugin). Please check if this issue appears when:
- Only Toolset plugins are activated. It will tell us if there is an interaction issue with another plugin.
- The theme is set to a WordPress default like Twenty-Twenty. It will tell us if there is an interaction issue with your theme.
If the problem disappears, start activating one at a time to track where the incompatibility is produced.

Let me know if I can run similar tests on this BlogVault install.

If this does not help find the origin of the issue, we'll need to take a copy of your website for further debugging locally. Let me know if you would agree?

#1844413

Hi Jamal, and thank you for replying on the weekend - because I'm working too! 😉

I realized shortly after I read your reply above that I hadn't implemented the edit form correctly; I had added it directly to the single product template created earlier, rather than putting it in its own template and adding that to the product template so that it appears as an 'Edit' link. However, after doing so the problem still persists.

I then disabled all plugins except Toolset's and WooCommerce (that's needed because the form where the problem is showing up is for editing products). I also switched themes from a Storefront child theme to Twentytwenty. The problem didn't go away, so I switched the theme back and re-activated plugins.

So yes, please do take a copy of the website for further debugging. If you can do so directly, please do; if I need to assist in some way, just let me know.

And thank you again for helping with this!

#1845697

Duplicator failed to make a copy of the website, I took an All In One Migration export and I'll be working on it locally. I'll get back to you as soon as possible.

#1845939

It seems that the issue came from the conditions in the fields:
- Only display Recording Date year
- Only display Release Date year

I edited both conditions and I updated them to be greater than 1969 December 31st and it fixed the issue. The old conditions were not consistent, one was (>1/1/1970) and the other (>1/1/70).

So, I wonder what is the condition that you were(want) implementing? Literally date should be after 1/1/1970? or date field should not be empty?

#1846049

If I recall correctly, back when I constructed those conditions (last year sometime?) there wasn't a test for empty/not-empty - that is indeed the appropriate test desired in these two cases. Do please let me know what the correct text to use here is! And thank you for tracking this down!

#1846073

Because the field is a date field, the user interface won't allow choosing the EMPTY function, so we work around it by editing the condition on the "Advanced text mode" and replace the DATE function with an empty string ('': two single quotes).

First, choose the operator "Not identical to" hidden link
Then switch to advanced mode and replace the DATE function to an empty string hidden link

($(recording-date) ne '')
#1846197

My issue is resolved now. Thank you!