carbon-fields icon indicating copy to clipboard operation
carbon-fields copied to clipboard

Term meta + image field produces JS error. Unable to update.

Open SteveRyan-ASU opened this issue 6 years ago • 1 comments

Version

  • Carbon Fields: 3.1.10
  • WordPress: 5.3.2
  • PHP: 7.3

Behavior

I have a term meta container with an image field associated with it. When attempting to edit an existing term's meta, a JS error in metabox.min.js prevents me from saving a new image or recalling the saved image from the DB.

Term meta images that had previously been saved to the DB are displayed correctly.

All other field types within term meta boxes that I've tried still update successfully.

Container definition

Container::make( 'term_meta', 'Details' )
->add_fields(
	array(
		Field::make( 'image', 'example_image', 'Example Image' ),
	)

Steps to Reproduce the Problem

  1. Create a term metabox with an image field within it.
  2. Navigate to wp-admin/term.php
  3. The console should show the error captured below.
  4. The same error occurs when you add a new term from wp-admin/edit-tags.php, although it is not present when the page first loads.

Error

metaboxes.min.js?ver=3.1.10:formatted:1769 Uncaught TypeError: Cannot read property 'indexOf' of null
    at metaboxes.min.js?ver=3.1.10:formatted:1769
    at vendor.min.js?ver=3.1.10:23
    at metaboxes.min.js?ver=3.1.10:formatted:546
    at HTMLDocument.o (metaboxes.min.js?ver=3.1.10:formatted:348)
    at HTMLDocument.dispatch (load-scripts.php?c=0&load[chunk_0]=jquery-core,jquery-migrate,utils,moxiejs,plupload&ver=5.3.2:3)
    at HTMLDocument.r.handle (load-scripts.php?c=0&load[chunk_0]=jquery-core,jquery-migrate,utils,moxiejs,plupload&ver=5.3.2:3)
    at Object.trigger (load-scripts.php?c=0&load[chunk_0]=jquery-core,jquery-migrate,utils,moxiejs,plupload&ver=5.3.2:3)
    at Object.a.event.trigger (load-scripts.php?c=0&load[chunk_0]=jquery-core,jquery-migrate,utils,moxiejs,plupload&ver=5.3.2:8)
    at x (load-scripts.php?c=0&load[chunk_0]=jquery-core,jquery-migrate,utils,moxiejs,plupload&ver=5.3.2:4)
    at XMLHttpRequest.c (load-scripts.php?c=0&load[chunk_0]=jquery-core,jquery-migrate,utils,moxiejs,plupload&ver=5.3.2:4)

When looking at the error in the browser, the offending line in the "un-minified" file appears to be line 1769.

SteveRyan-ASU avatar Dec 18 '19 23:12 SteveRyan-ASU

Have similar problem with conditions (Carbon Fields: 3.1.10;WordPress: 5.3.2;PHP: 7.1) Addin this simple code

Container::make('post_meta', __('Product options', 'ssulub'))
        ->where('post_type', '=', 'product')
        ->add_fields(array(
            Field::make('complex', 'options', __('Options', 'ssulub'))
                ->add_fields(array(
                    Field::make('select', 'option', __('Option', 'ssulub'))
                        ->set_width(50)
                        ->set_options([
                            '1' => 'one',
                            '2' => 'second'
                        ]),
                    )),
                    Field::make('text', 'option_value', __('Value', 'ssulub'))
                        ->set_width(50)
                        ->set_conditional_logic( array(
                            array(
                                'field' => 'option',
                                'compare' => 'NOT IN',
                                'value' => ['2']
                            )
                        )),
                    Field::make('select', 'option_value_2', __('Value', 'ssulub'))
                        ->set_width(50)
                        ->set_options([
                            '1' => 'one',
                            '2' => 'second'
                        ])
                        ->set_conditional_logic( array(
                            array(
                                'field' => 'option',
                                'value' => '1'
                            )
                        ))
            ));

and have error in console An unknown field is used in condition - "option"

Maby it's not related

vanilium avatar Dec 19 '19 16:12 vanilium