Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

complex fields issue on carbon fields upgrade from 1.6 to 3.1 #45

Open
Eneva opened this issue Apr 30, 2019 · 0 comments
Open

complex fields issue on carbon fields upgrade from 1.6 to 3.1 #45

Eneva opened this issue Apr 30, 2019 · 0 comments

Comments

@Eneva
Copy link

Eneva commented Apr 30, 2019

When upgrading carbon fields from version 1.6 to 3.1 I experience the following problem:

I have two complex fields with same names on two different pages.

code example on page 1:
Container::make('post_meta','Home fields')
->where('post_id', '=', get_option( 'page_on_front' ))
->add_tab('Benefits',array(
Field::make('complex', 'benefits')
->set_layout('tabbed-horizontal')
->setup_labels(array(
'singular_name' => 'Benefit',
'plural_name' => 'Benefits',
))
->add_fields('benefit', array(
Field::make('image', 'image','Image')
Field::make('text', 'title','Title'),
Field::make('textarea', 'description','Description'),
))
))

code example on page 2:
Container::make('post_meta','City Service Page Fields')
->where( 'post_type', '=', 'city_page' )
->add_tab('Tab 1', array(
Field::make('complex','benefits', 'How it works')
->set_layout('tabbed-horizontal')
->setup_labels(array(
'singular_name' => 'Benefit',
'plural_name' => 'Benefits',
))
->add_fields('benefit', array(
Field::make('image','process_thumbnail', 'Thumbnail')
Field::make('text', 'benefit_title', 'Benwfit title')
Field::make('textarea', 'benefit_text', 'Benefit text')
))
))

On example page 2 I call the fields
carbon_get_post_meta(post->ID, 'benefits');

It tries to return the field values for example page 2, using the field names from example page 1. It seems that it uses the first found complex field name, no matter of the page ID.
The result is below:
[0]=>
array(4) {
["_type"]=>
string(7) "benefit"
["image"]=>
string(0) ""
["title"]=>
string(0) ""
["description"]=>
string(0) ""
}

The result should be:
[0]=>
array(4) {
["_type"]=>
string(7) "benefit"
["process_thumbnail"]=>
string(0) ""
["benefit_title"]=>
string(4) "test"
["benefit_text"]=>
string(4) "test"
}

Is there some work around to get the right values ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant