• Resolved ricomoorman

    (@ricomoorman)


    Hello,

    I am getting the following error when using the most recently released version 5.3.0 of this plugin:

    
    TypeError: r is undefined.  Exception occurred when checking element _product_price, check the 'currency' method. validation.min.js:18:6063
        <anonymous> https://example.com/wp-content/plugins/meta-box/js/validation.min.js?ver=5.3.0:18
        check https://example.com/wp-content/plugins/meta-box/js/validation.min.js?ver=5.3.0:9
        checkForm https://example.com/wp-content/plugins/meta-box/js/validation.min.js?ver=5.3.0:9
        form https://example.com/wp-content/plugins/meta-box/js/validation.min.js?ver=5.3.0:9
        validate https://example.com/wp-content/plugins/meta-box/js/validation.min.js?ver=5.3.0:9
        jQuery 2
            dispatch
            handle
    

    Downgrading to 5.2.10 does resolve the issue temporarily.

    This error occurs upon clicking the wordpress save/publish buttons while having a few fields defined on a custom post type. The user is asked whether it wants to stay on the page or leave (browser popup for navigating away from filled/changed forms). The post is not being saved either way, so it seems that this error breaks the wordpress save functionality.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Anh Tran

    (@rilwis)

    Hi @ricomoorman ,

    Can you share that registers meta boxes and fields? We need that to check the validation rules you made.

    Thanks.

    Thread Starter ricomoorman

    (@ricomoorman)

    We create a bunch of meta box instances like this:

    
    $meta_boxes = array(
        0 => array(
            'id' => 'product',
            'title' => 'Product information',
            'pages' => array(
                0 => 'example_product',
            ),
            'context' => 'normal',
            'priority' => 'high',
            'fields' => array(
                0 => array(
                    'name' => 'price',
                    'desc' => 'example: 19,95',
                    'id' => '_product_price',
                    'type' => 'currency',
                    'std' => '0',
                ),
                1 => array(
                    'name' => 'subtext',
                    'desc' => 'example: now instead of € 39,95 you only pay',
                    'id' => '_product_sidenote',
                    'type' => 'text',
                    'std' => '0',
                ),
                2 => array(
                    'name' => '',
                    'desc' => 'Product information (e.g. a discount). Not orderable directly',
                    'id' => '_product_information',
                    'type' => 'checkbox',
                    'std' => '0',
                ),
                3 => array(
                    'name' => 'Supply',
                    'desc' => '',
                    'id' => '_product_supply',
                    'type' => 'text',
                    'std' => '0',
                ),
                4 => array(
                    'name' => '',
                    'desc' => 'Unlimited amount?',
                    'id' => '_product_supply_infinite',
                    'type' => 'checkbox',
                    'std' => '0',
                ),
                5 => array(
                    'name' => 'Max. order amount',
                    'desc' => '',
                    'id' => '_product_max_per_order',
                    'type' => 'text',
                    'std' => '0',
                ),
                6 => array(
                    'name' => 'Date',
                    'desc' => 'E.g. for an event',
                    'id' => '_product_date',
                    'type' => 'date',
                ),
                7 => array(
                    'name' => 'Waitinglist',
                    'desc' => 'In case there are waiting list spots available',
                    'id' => '_product_waitinglist',
                    'type' => 'text',
                    'std' => '0',
                ),
            ),
        ),
        1 => array(
            'id' => 'options',
            'title' => 'Options',
            'pages' => array(
                0 => 'example_product',
            ),
            'context' => 'normal',
            'priority' => 'high',
            'fields' => array(
                0 => array(
                    'name' => '',
                    'desc' => 'This product can be collected at the store (store can be selected when ordering)',
                    'id' => '_product_select-dealer',
                    'type' => 'checkbox',
                    'std' => '0',
                ),
                1 => array(
                    'name' => '',
                    'desc' => 'Product is visible',
                    'id' => '_product_visible',
                    'type' => 'checkbox',
                    'std' => '0',
                ),
                2 => array(
                    'name' => 'Starting date',
                    'desc' => 'When the product will be orderable',
                    'id' => '_product_startdate',
                    'type' => 'date',
                    'std' => '',
                ),
                3 => array(
                    'name' => 'Eind datum',
                    'desc' => 'When the product will not be orderable anymore',
                    'id' => '_product_enddate',
                    'type' => 'date',
                    'std' => '',
                ),
                4 => array(
                    'name' => '',
                    'desc' => 'Product of the month?',
                    'id' => '_product_product-of-the-month',
                    'type' => 'checkbox',
                    'std' => '0',
                ),
                5 => array(
                    'name' => '',
                    'desc' => 'Visible on homepage?',
                    'id' => '_product_homepage',
                    'type' => 'checkbox',
                    'std' => '0',
                ),
            ),
        ),
        2 => array(
            'id' => 'email',
            'title' => 'Confirmation e-mail',
            'pages' => array(
                0 => 'example_product',
            ),
            'context' => 'normal',
            'priority' => 'high',
            'fields' => array(
                0 => array(
                    'name' => '',
                    'desc' => '',
                    'id' => '_product_confirmation-email',
                    'type' => 'wysiwyg',
                    'std' => 'Dear member,
    
    Thank you for your order:
    [COUNT] x [PRODUCT]
    
    Best regards
    
    example.com',
                    'teeny' => true,
                ),
            ),
        ),
        3 => array(
            'id' => 'form',
            'title' => 'Form',
            'pages' => array(
                0 => 'example_product',
            ),
            'context' => 'normal',
            'priority' => 'high',
            'fields' => array(
                0 => array(
                    'name' => 'Form',
                    'desc' => 'Select an additional form that has to be filled in',
                    'id' => '_product_extra-form',
                    'type' => 'select',
                    'options' => array(
                        0 => '',
                    ),
                    'std' => '',
                ),
            ),
        ),
        4 => array(
            'id' => 'summary',
            'title' => 'Summary',
            'pages' => array(
                0 => 'example_product',
            ),
            'context' => 'normal',
            'priority' => 'high',
            'fields' => array(
                0 => array(
                    'name' => '',
                    'desc' => '',
                    'id' => '_product_summary',
                    'type' => 'wysiwyg',
                    'std' => '',
                    'teeny' => true,
                    'rows' => 5,
                ),
            ),
        ),
    );
    
    foreach ($meta_boxes as $meta_box) {
        if ($meta_box['id'] == 'form') {
            add_action("rwmb_after_{$meta_box['id']}", 'add_meta_export_button');
        } else {
            add_action("rwmb_after_{$meta_box['id']}", 'add_meta_save_button');
        }
    
        new RW_Meta_Box($meta_box);
    }
    

    Within admin_init … of course a lot of other things are going on in there too so I only posted the sections that seem relevant for the meta box plugin. In case you are wondering why there are numerical indexes within the array, I just did a var_export($meta_boxes) to get the result of the things going on/building the meta boxes array in the init function.

    Please let me know if there is anything else I need to provide!

    Plugin Support longnguyen

    (@longnguyen)

    Hi,

    The plugin Meta Box has not supported the field type currency yet. Did you create the custom field type currency?

    If not, please follow this documentation https://docs.metabox.io/custom-field-type/.

    Thread Starter ricomoorman

    (@ricomoorman)

    @longnguyen , switching from “currency” to “number” helped a lot :-). The original developer of the theme in question set an invalid field type. It seems that the newest version is just not as forgiving as version 5.2.10.

    Thank you very much for your help and keep up the good work!

    • This reply was modified 5 years, 11 months ago by ricomoorman.
Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘TypeError: r is undefined’ is closed to new replies.