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

Association field value is not loading - "Call to a member function get_thumbnail_by_type() on null" 2

Open TheJema opened this issue 4 years ago • 1 comments

Version

  • Carbon Fields: 3.3.2
  • WordPress: 5.8
  • PHP: 7.4

Actual Behavior

After saving the data and refreshing the page, the selected values are not shown https://prnt.sc/22syk4n

Container definition

 Field::make('association', 'selectedpost', esc_html__('Select post:', 'plg')) ->set_max( 1 )
                ->set_types(array(
                    array(
                        'type' => 'post',
                        'post_type' => 'ccpost',
                    ),
                ))

Comments

The problem only appears when using WPML and specifically for the Russian language. If you do it for English, it's fine. In the browser console there is the following error: https://prnt.sc/22sx911

TheJema avatar Dec 13 '21 12:12 TheJema

Hello!

The problem hasn't been resolved yet.

There is also an error when selecting a post in the association field, when scrolling through the records, an error is displayed specifically for the Russian language in WPML.

Image Error: https://prnt.sc/hT8ldxVlrL9L

PHP error: Fatal error: Uncaught Error: Call to a member function get_options() on null in /carbon-fields/vendor/htmlburger/carbon-fields/core/REST_API/Router.php:360

I believe that the problem is due to the fact that nothing works here in Router.php $field = Helper::get_field( null, $container_id, $field_id );

address page where the rest-api request goes when loading new elements in the association field https://sitename.com/ru/wp-json/carbon-fields/v1/association/options?container_id=carbon_fields_container_casino_fields&options=7172%3Apost%3Acasino&field_id=azart_plugin_bonus_casino&term=&page=2

I would be grateful for any answer, thanks

TheJema avatar Jun 22 '22 08:06 TheJema

Still supported?

TheJema avatar Dec 22 '22 16:12 TheJema

@TheJema , I solved this issue with removing i18n function from theme-options initialization:

before: Container::make('theme_options', __('Theme Options')) ->set_icon('dashicons-heart') ...

after: Container::make('theme_options', 'Theme Options') ->set_icon('dashicons-heart') ...

hexando avatar Jan 12 '23 16:01 hexando

Awesome

oleg-kalinovskiy avatar Jan 12 '23 16:01 oleg-kalinovskiy

Currently, there is an issue with translating Cyrillic symbols. The library is trying to create a slug for all pages but the Cyrillic symbols are returning empty symbols. In order to fix this issue, please try using the set_page_file method with ASCI symbols only like this:

Container::make( 'theme_options', __( 'Шапка', 'pr' ) )
            ->set_page_file('header-options.php')

We would fix this issue in the next release.

HTMLBurger-NG avatar Feb 20 '23 09:02 HTMLBurger-NG