Field type 'key_value' gives notice: array to string conversion

Support General Field type 'key_value' gives notice: array to string conversion

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #16906
    YardYard
    Participant

    Hello,

    I've created a metabox field with the type 'key_value'. when viewing my metabox field it displays an notice: Notice: Array to string conversion in /Users/User/Desktop/Development/project-kwintes-portal/htdocs/wp-content/plugins/meta-box/inc/fields/key-value.php on line 101. This only happens while creating a new page.

    Here is an example of my code:

    
    [
        'id'          => "{$keyName}_scroll_tabs",
        'name'        => __('Vul de titel in en het ID in van het element waar naartoe gescrollt dient te worden.', 'fusion'),
        'type'      => 'key_value',
        'placeholder' => ['key' => 'Titel', 'value' => 'Anchor ID'],
        'multiple'      => true,
        'clone'       => true,
        'add_button' => __('Set toevoegen', 'fusion')
    ]
    

    When I create the page en publish it the Notice is gone.

    #16929
    Anh TranAnh Tran
    Keymaster

    I've just tried with the code and don't see the notice. Can you check that again?

    #17076
    YardYard
    Participant

    As college of topic starter, I dug a bit deeper, and found that adding a default, did help:

    
    [
        'id'          => "{$keyName}_scroll_tabs",
        'name'        => __('Vul de titel in en het ID in van het element waar naartoe gescrollt dient te worden.', 'fusion'),
        'type'      => 'key_value',
        'placeholder' => ['key' => 'Titel', 'value' => 'Anchor ID'],
        'std' => ['key' => ''],
        'multiple'      => true,
        'clone'       => true,
        'add_button' => __('Set toevoegen', 'fusion')
    ]
    

    Maybe it's useful to add a default value of an empty string.

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