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

Assosiation field inside complex field do not save

Open erimeilis opened this issue 5 years ago • 4 comments

Version

  • Carbon Fields: 3.1.20
  • WordPress: 5.4.2
  • PHP: 7.4

Expected Behavior

I add association field inside the complex field. Expect it just to work (to save).

Actual Behavior

After i save it, i get selected term disappear from the selected list (though i can't add it one more time, cos "plus" signs are not present for these terms. Also i get

load-scripts.php?c=1&load[chunk_0]=jquery-core,jquery-migrate,utils,moxiejs,plupload&ver=5.4.2:4 GET https://imeat.redshoes.pro/wp-json/carbon-fields/v1/association/?container_id=carbon_fields_container__&options=19%3Aterm%3Aproduct_cat%3B32%3Aterm%3Aproduct_cat%3B16%3Aterm%3Aproduct_cat&field_id=crb_wooproductoptions%5B0%5D%3A_%2Foption_cats 500 Show 8 more frames admin.php?page=crb_carbon_fields_container.php:1 Uncaught (in promise) Произошла ошибка.

Container definition

Field::make( 'complex', 'crb_wooproductoptions', __( 'Woo custom product options' ))
            ->set_collapsed( true )
            ->add_fields( array(
            	Field::make( 'text', 'option_name', 'Option name' ),
            	Field::make( 'text', 'option_price', 'Option price' ),
            	Field::make( 'association', 'option_cats', 'Option product categories')
    				->set_types( array(
        				array(
            				'type' => 'term',
            				'taxonomy' => 'product_cat',
        				),
            	))
            ))

Steps to Reproduce the Problem

  1. Install CF via composer into the theme
  2. Install Woocommerce
  3. Add code to your theme functions
  4. Try to save

Comments

erimeilis avatar Aug 10 '20 14:08 erimeilis

https://github.com/htmlburger/carbon-fields/issues/636#issuecomment-748142890 I did big reply to this closed issue, i think my problem is same here. Still not resolved.

norixx avatar Dec 19 '20 03:12 norixx

Struggling with the same issue. Am using complex fields in theme_options to allow users to select pages. When saving associations in a tabbed complex field in theme_options, I can set an association, and after it's set and saved, it isn't displayed on the list. The only error returned in console when accessing the field is "Uncaught (in promise) An error occured"

I also noticed, that every time I set and save an association, it causes all other association arrays to become empty. But if I set multiple associations and save them all at once, all of them are saved correctly in their own arrays, but the association list doesn't display anything for any of them (plus icon has disappeared as well).

I'm also mixing things up with Polylang. It seems that the associations work if site default language is in use, but if I use the admin panel with alternative languages, the above is the result. I'm of course setting a language identifier for the fields and retrieve data using it as well.

Basically this forces me to use clumsy text fields to enable users to enter links to different internal pages.

pullasuti avatar Mar 25 '21 11:03 pullasuti

I have the same issue. Or a similar one. When I save my association inside a complex, it shows the field as empty and I can see the "Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'id')" error in the console inside Theme Options container. Inside the Gutenberg - it may crush the whole block. Also adding the conditional logic to it causes a crush sometimes. I regret using Carbon Fields, it seems like it's too unstable and unsupported to build with. Every day I stumble across the major issues that hadn't beed fixed in years. Too bad it will take me ages to rebuild my site with ACF

pshechko avatar Feb 23 '24 23:02 pshechko