Empty cloneable date field give critical WordPress error in PHP8.1
- This topic has 1 reply, 2 voices, and was last updated 9 months, 4 weeks ago by
Peter.
-
AuthorPosts
-
January 10, 2025 at 10:12 AM #47360
Care Digital
ParticipantHello, Metabox support.
We have created Event CPT with multiple date fields, one of which is a cloneable and sortable date field, saving in Ymd format.
Upon saving, it results in critical error. Please see the log below.
Error Details
=============
An error of type E_ERROR was caused in line 216 of the file /home/care-digital/webapps/demo/wp-content/plugins/meta-box/inc/fields/datetime.php. Error message: Uncaught TypeError: RWMB_Datetime_Field::from_save_format(): Return value must be of type string, null returned in /home/care-digital/webapps/demo/wp-content/plugins/meta-box/inc/fields/datetime.php:216
Stack trace:
#0 [internal function]: RWMB_Datetime_Field::from_save_format()
#1 /home/care-digital/webapps/demo/wp-content/plugins/meta-box/vendor/meta-box/support/Arr.php(22): call_user_func_array()
#2 [internal function]: MetaBox\Support\Arr::MetaBox\Support\{closure}()
#3 /home/care-digital/webapps/demo/wp-content/plugins/meta-box/vendor/meta-box/support/Arr.php(20): array_map()
#4 /home/care-digital/webapps/demo/wp-content/plugins/meta-box/inc/fields/datetime.php(185): MetaBox\Support\Arr::map()
#5 /home/care-digital/webapps/demo/wp-content/plugins/meta-box/inc/field.php(541): RWMB_Datetime_Field::meta()
#6 /home/care-digital/webapps/demo/wp-content/plugins/meta-box/inc/field.php(25): RWMB_Field::call()
#7 /home/care-digital/webapps/demo/wp-content/plugins/meta-box/inc/field.php(541): RWMB_Field::show()
#8 /home/care-digital/webapps/demo/wp-content/plugins/meta-box/inc/meta-box.php(218): RWMB_Field::call()
#9 /home/care-digital/webapps/demo/wp-admin/includes/template.php(1456): RW_Meta_Box->show()
#10 /home/care-digital/webapps/demo/wp-admin/edit-form-advanced.php(722): do_meta_boxes()
#11 /home/care-digital/webapps/demo/wp-admin/post.php(206): require('..')
#12 {main}
thrownAll the other date fields are fine when left empty, but not this cloneable field. Deleting this field solves the issue. Any help is appreciated.
Best regards,
WiratJanuary 10, 2025 at 10:53 PM #47368Peter
ModeratorHello Wirat,
I'm not able to reproduce the issue on my site. I can save an empty value for the cloneable datetime field. Can you please try to change the field ID to another one and save the post again?
If it still doesn't work, please export the field group to a JSON file and share it here. I will help you check the issue.
Following the documentation https://docs.metabox.io/extensions/meta-box-builder/ -
AuthorPosts
- You must be logged in to reply to this topic.