Empty cloneable date field give critical WordPress error in PHP8.1

Support General Empty cloneable date field give critical WordPress error in PHP8.1

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #47360
    Care DigitalCare Digital
    Participant

    Hello, 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}
    thrown

    All 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,
    Wirat

    #47368
    PeterPeter
    Moderator

    Hello 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/

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.