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

Text fields get prepopulated

Open Geckoff opened this issue 8 years ago • 4 comments

Version

  • Carbon Fields: 2.1
  • WordPress: 4.9.4
  • PHP: 5.6.3

Expected Behavior

Adding new posts with no issues :)

Actual Behavior

The issue I'm coming across related to Carbon Fields text fields. I am using Carbon Fields with a custom post type. Also, I am using 'save_post' hook for this post type and retrieving Carbon Fields values with carbon_get_post_meta() in the function attached to the hook. When I'm trying to create a new post of my custom post type, I am getting text fields populated with the values from the first post published. This prepopulation occurs only for the fields I am using carbon_get_post_meta() for.

Container definition

Container::make( 'post_meta', __( 'General Info', 'crb' ) )
	->where( 'post_type', '=', 'jsdisplay' )
	->add_fields( array(
		Field::make( 'text', 'jsdid', 'ID' )
			->set_attribute( 'pattern', '[a-z]+[a-z0-9-_]*[a-z0-9]+' )
			->set_required( true )
			->set_help_text('May contain only lowercase letters, numbers, "-" and "_" characters and should start with a letter and end with a letter or a number.'),
		Field::make( 'select', 'jsd_css_display', 'CSS display type' )
			->add_options( array(
				'block' => 'Block',
				'inline' => 'Inline',
				'inline-block' => 'Inline Block',
				'flex' => 'Flex',
			) )
			->set_help_text('Used for JS display functionality.')
	) );

Comments

Was able to overcome this issue by using native Wordpress get_post_meta function instead of carbon_get_post_meta.

Geckoff avatar Mar 04 '18 01:03 Geckoff

Hi @Geckoff ,

I believe this issue was addressed in one of the 2.2 beta releases. Kindly test with the latest beta release and let us know if the issue is resolved.

atanas-dev avatar Mar 04 '18 07:03 atanas-dev

Sorry, apparently I specified the wrong version. I am using one that is on master branch now. As far as I understand it's 2.2.0-beta.5.

Geckoff avatar Mar 04 '18 17:03 Geckoff

Hi @Geckoff ,

Unfortunately, I can't reproduce your issue (version 2.2.0) so can you provide more information about your use case?

deqngeorgiev avatar Apr 04 '18 07:04 deqngeorgiev

Closing due to inactivity.

@Geckoff feel free to open a new issue if you experience the problem again.

jorostoyanov avatar Oct 30 '18 10:10 jorostoyanov