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

Can't get Complex field value #52

Open
oooh-boi opened this issue Sep 7, 2019 · 1 comment
Open

Can't get Complex field value #52

oooh-boi opened this issue Sep 7, 2019 · 1 comment

Comments

@oooh-boi
Copy link

oooh-boi commented Sep 7, 2019

CF: v3.1.2
WP: 5.3.2
PHP: 7.2.14

Been using CF since version 2 but I'm not sure whether I'm so old or there's really something wrong.

I have a complex field with a group of two text fields and 2 date fields inside. Nothing too fancy or unusual. That complex field is a part of the tab container.

Field::make( 'complex', 'bm_seasonal_prices', esc_attr__( 'Create exception in accommodation price', 'bookmate' ) )
->set_duplicate_groups_allowed( true )
->add_fields( array(

	Field::make( 'text', 'bm_exception_title', esc_attr__( 'Exception title', 'bookmate' ) )
	->set_width( 100 ),

	Field::make( 'date', 'bm_exception_date_start', esc_attr__( 'Exception date start', 'bookmate' ) )
	->set_storage_format( Bookmate::bookmate_date_format() )
	->set_width( 33 ),
	
	Field::make( 'date', 'bm_exception_date_end', esc_attr__( 'Exception date end', 'bookmate' ) )
	->set_storage_format( Bookmate::bookmate_date_format() )
	->set_width( 33 ),
	
	Field::make( 'text', 'bm_exception_date_range_price', esc_attr__( 'Exceptional price', 'bookmate' ) )
	->set_width( 33 )
	->help_text( esc_attr__( 'Price must be in format: 1234.56 (dot notation).', 'bookmate' ) ),
	
) )
->set_header_template( '
	<% if (bm_exception_title) { %>
		<%- bm_exception_title %>
	<% } %>
' )

By trying to get the value of my complex field, I get an empty array...

$seasons_arr = carbon_get_post_meta( $pid, 'bm_seasonal_prices', 'complex' );

Here's the Post Meta Inspector result screenshot too. I know that WordPress pipe-separates multiple meta values but not sure whether they get properly parsed by CF.
cf_post_meta_complex

I desperately need help. PLEASE!

@JuanBernal98
Copy link

Is not working like that?

$seasons_arr = carbon_get_post_meta( $pid, 'bm_seasonal_prices');

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

2 participants