Issue with saving field value when block has a number field

Support MB Blocks Issue with saving field value when block has a number field

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #47647
    Cédric DagherirCédric Dagherir
    Participant

    Hi, I have This error with the latest MB Blocks version :

    [13-Feb-2025 11:44:49 Europe/Paris] PHP Fatal error:  Uncaught TypeError: Unsupported operand types: string + int in /mysite/web/app/plugins/mb-blocks/src/Block.php:264
    Stack trace:
    #0 /mysite/web/app/plugins/mb-blocks/src/Block.php(70): MBBlocks\Block->sanitize_data()
    #1 /mysite/web/wp/wp-includes/class-wp-hook.php(324): MBBlocks\Block->save_block()
    #2 /mysite/web/wp/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters()
    #3 /mysite/web/wp/wp-includes/plugin.php(517): WP_Hook->do_action()
    #4 /mysite/web/wp/wp-admin/admin-ajax.php(192): do_action()
    #5 {main}
      thrown in /mysite/web/app/plugins/mb-blocks/src/Block.php on line 264

    I fixed it by replacing with :

    			if ( 'number' === $value['type'] ) {
    				$data[ $key ] = (int)$data[ $key ] + 0;
    			}

    in the plugin. I don't know if it's the right way to proceed but there is something to fix here !

    Thanks

    #47652
    PeterPeter
    Moderator

    Hello Cedric,

    Thanks for your feedback.

    Can you please share the code that you use to register the custom block and output the block data? I'm not able to reproduce the issue on my site. If you are using the builder, you can follow the documentation to export the field group to a JSON file
    https://docs.metabox.io/extensions/meta-box-builder/#export--import

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