GithubHelp home page GithubHelp logo

htmlburger / carbon-fields-docs Goto Github PK

View Code? Open in Web Editor NEW
81.0 81.0 61.0 1.99 MB

Documentation and guides for Carbon Fields.

Home Page: https://docs.carbonfields.net

Vue 5.74% JavaScript 90.13% Stylus 4.13%

carbon-fields-docs's People

Contributors

azizalmazbekuulu avatar dependabot[bot] avatar emohamed avatar ibes avatar jorostoyanov avatar nadimd avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

carbon-fields-docs's Issues

Have a bug with image radio buttons

I create the Gutenberg block with the image radio field. After adding several these blocks, all radio inputs have an identical name, and it's no abled to save value for each block

Gutenberg Blocks Category

Hello,
I'm developping 2 WP Plugins and use Carbon Fields 3 to create Gutenbergs Block.
if the both plugins are activated then all blocks (with different category name) are grouped in the same Category :-/

Compatibility PHP 7.2 and Gutenberg blocks

Hi!

First of all; what a great plugin!! So much custom fields and all within code!

But as I'm running PHP7.2 and creating a custom block, the frontend throws an error:
"Warning: count(): Parameter must be an array or an object that implements Countable in /app/public/wp-includes/post-template.php on line 284"

When I deleted that block from the page or change my local server to 7.1, error is gone. I'm guessing something is incompatible with 7.2.

Any change this getting fixed? Thanks in advance!

Error in term meta condition type docs

post_meta container is used in example where term_meta should be used

// Display container on Book Category taxonomy
Container::make( 'post_meta', __( 'Book Category Data' ) )
    ->where( 'term_taxonomy', '=', 'crb_book_category' )
    ->add_fields( array( .. ) );

Should be

// Display container on Book Category taxonomy
Container::make( 'term_meta', __( 'Book Category Data' ) )
    ->where( 'term_taxonomy', '=', 'crb_book_category' )
    ->add_fields( array( .. ) );

https://docs.carbonfields.net/#/containers/condition-types?id=term_meta-conditions

Complex field label isn't visible

Hi,
I don't know if this is an issue, or I make a mistake.
In the backend, the labels "Model-Galerie" and "Neuigkeiten" are visible, but not the complex field "Slideshow".
It's an empty list element in the backend, but it is working well. Only the label isn't visible after clicking "add new entry"

I have this code:

->add_fields('model-gallery', 'Model-Galerie', array(
    Field::make('media_gallery', 'media_gallery')
        ->set_type(array('image')),
))
->add_fields('news', 'Neuigkeiten', array(
    Field::make('text', 'heading', 'Überschrift - 1.'),
    Field::make('text', 'heading_second', 'Überschrift - 2.'),
))
->add_fields(array(
    Field::make('complex', 'slider', 'Slideshow')
        ->set_layout('tabbed-horizontal')
        ->add_fields(array(
            Field::make('text', 'heading', 'Überschrift - 1. Zeile'),
            Field::make('text', 'heading_second', 'Überschrift - 2. Zeile'),
            Field::make('image', 'image', 'Image'),
            Field::make('checkbox', 'has_button', 'Button hinzufügen?'),
            Field::make('text', 'button_label', 'Button-Beschriftung')
                ->set_conditional_logic(array(
                    array(
                        'field' => 'has_button',
                        'value' => true,
                    )
                )),
            Field::make('text', 'button_url', 'Button-Url')
                ->set_conditional_logic(array(
                    array(
                        'field' => 'has_button',
                        'value' => true,
                    )
                )),
        )),
))

Sorry, wrong repo...

errors when deleting complex field items

I am seeing the following errors in chrome's dev tools when trying to delete an item in a complex field:

index.js:41 Uncaught TypeError: Cannot read property 'fields' of undefined
at getFieldsFromFieldsHolder (index.js:41)
at output (index.js:129)
at eval (index.js:66)
at Object.eval [as next] (index.es.js:219)
at eval (readme.js:53)
at eval (VM64436 callbag-distinct-until-changed.es.js:34)
at eval (VM64093 readme.js:48)
at eval (from-selector.js:28)
at data.js?ver=4.4.0:1362
at Array.forEach ()
getFieldsFromFieldsHolder @ index.js:41
output @ index.js:129
(anonymous) @ index.js:66
(anonymous) @ index.es.js:219
(anonymous) @ readme.js:53
(anonymous) @ callbag-distinct-until-changed.es.js:34
(anonymous) @ VM64093 readme.js:48
(anonymous) @ from-selector.js:28
(anonymous) @ data.js?ver=4.4.0:1362
globalListener @ data.js?ver=4.4.0:1361
(anonymous) @ data.js?ver=4.4.0:685
dispatch @ data.js?ver=4.4.0:3467
(anonymous) @ data.js?ver=4.4.0:558
(anonymous) @ data.js?ver=4.4.0:613
(anonymous) @ data.js?ver=4.4.0:778
proxyDispatch @ data.js?ver=4.4.0:2168
container. @ index.es.js:248
container. @ index.es.js:248
(anonymous) @ index.js:138
(anonymous) @ index.js:135
(anonymous) @ group.js:82
callCallback @ react-dom.js?ver=16.8.4:143
invokeGuardedCallbackDev @ react-dom.js?ver=16.8.4:193
invokeGuardedCallback @ react-dom.js?ver=16.8.4:250
invokeGuardedCallbackAndCatchFirstError @ react-dom.js?ver=16.8.4:264
executeDispatch @ react-dom.js?ver=16.8.4:555
executeDispatchesInOrder @ react-dom.js?ver=16.8.4:577
executeDispatchesAndRelease @ react-dom.js?ver=16.8.4:674
executeDispatchesAndReleaseTopLevel @ react-dom.js?ver=16.8.4:682
forEachAccumulated @ react-dom.js?ver=16.8.4:656
runEventsInBatch @ react-dom.js?ver=16.8.4:810
runExtractedEventsInBatch @ react-dom.js?ver=16.8.4:818
handleTopLevel @ react-dom.js?ver=16.8.4:4929
batchedUpdates$1 @ react-dom.js?ver=16.8.4:20528
batchedUpdates @ react-dom.js?ver=16.8.4:2149
dispatchEvent @ react-dom.js?ver=16.8.4:5008
(anonymous) @ react-dom.js?ver=16.8.4:20579
unstable_runWithPriority @ react.js?ver=16.8.4:735
interactiveUpdates$1 @ react-dom.js?ver=16.8.4:20578
interactiveUpdates @ react-dom.js?ver=16.8.4:2168
dispatchInteractiveEvent @ react-dom.js?ver=16.8.4:4985
Show 11 more frames
index.js:41 Uncaught TypeError: Cannot read property 'fields' of undefined
at getFieldsFromFieldsHolder (index.js:41)
at output (index.js:129)
at eval (index.js:66)
at Object.eval [as next] (index.es.js:219)
at eval (readme.js:53)
at eval (VM64436 callbag-distinct-until-changed.es.js:34)
at eval (VM64093 readme.js:48)
at eval (from-selector.js:28)
at data.js?ver=4.4.0:1362
at Array.forEach ()
getFieldsFromFieldsHolder @ index.js:41
output @ index.js:129
(anonymous) @ index.js:66
(anonymous) @ index.es.js:219
(anonymous) @ readme.js:53
(anonymous) @ callbag-distinct-until-changed.es.js:34
(anonymous) @ VM64093 readme.js:48
(anonymous) @ from-selector.js:28
(anonymous) @ data.js?ver=4.4.0:1362
globalListener @ data.js?ver=4.4.0:1361
(anonymous) @ data.js?ver=4.4.0:685
dispatch @ data.js?ver=4.4.0:3467
(anonymous) @ data.js?ver=4.4.0:558
(anonymous) @ data.js?ver=4.4.0:613
(anonymous) @ data.js?ver=4.4.0:778
proxyDispatch @ data.js?ver=4.4.0:2168
(anonymous) @ index.js:125
(anonymous) @ index.es.js:219
(anonymous) @ readme.js:53
(anonymous) @ VM64093 readme.js:48
(anonymous) @ VM64079 readme.js:27
(anonymous) @ VM64079 readme.js:27
(anonymous) @ VM64081 readme.js:31
next @ readme.js:58
(anonymous) @ index.es.js:233
(anonymous) @ index.es.js:232
instance.triggerUnmount @ index.es.js:293
WithEffects.componentWillUnmount @ index.es.js:358
callComponentWillUnmountWithTimer @ react-dom.js?ver=16.8.4:17258
callCallback @ react-dom.js?ver=16.8.4:143
invokeGuardedCallbackDev @ react-dom.js?ver=16.8.4:193
invokeGuardedCallback @ react-dom.js?ver=16.8.4:250
safelyCallComponentWillUnmount @ react-dom.js?ver=16.8.4:17265
commitUnmount @ react-dom.js?ver=16.8.4:17642
commitNestedUnmounts @ react-dom.js?ver=16.8.4:17673
unmountHostComponents @ react-dom.js?ver=16.8.4:17934
commitDeletion @ react-dom.js?ver=16.8.4:17993
commitAllHostEffects @ react-dom.js?ver=16.8.4:18774
callCallback @ react-dom.js?ver=16.8.4:143
invokeGuardedCallbackDev @ react-dom.js?ver=16.8.4:193
invokeGuardedCallback @ react-dom.js?ver=16.8.4:250
commitRoot @ react-dom.js?ver=16.8.4:19002
(anonymous) @ react-dom.js?ver=16.8.4:20507
unstable_runWithPriority @ react.js?ver=16.8.4:735
completeRoot @ react-dom.js?ver=16.8.4:20506
performWorkOnRoot @ react-dom.js?ver=16.8.4:20435
performWork @ react-dom.js?ver=16.8.4:20343
performSyncWork @ react-dom.js?ver=16.8.4:20317
interactiveUpdates$1 @ react-dom.js?ver=16.8.4:20584
interactiveUpdates @ react-dom.js?ver=16.8.4:2168
dispatchInteractiveEvent @ react-dom.js?ver=16.8.4:4985
Show 21 more frames
react-dom.js?ver=16.8.4:17206 The above error occurred in the component:
in WithEffects (created by ComponentWithDispatch)
in ComponentWithDispatch (created by Context.Consumer)
in WithDispatch(WithEffects) (created by ComponentWithDispatch)
in ComponentWithDispatch (created by Context.Consumer)
in WithDispatch(WithDispatch(WithEffects)) (created by WithEffects)
in WithEffects (created by ComponentWithSelect)
in ComponentWithSelect (created by Context.Consumer)
in WithSelect(WithEffects) (created by ComponentWithDispatch)
in ComponentWithDispatch (created by Context.Consumer)
in WithConditionalLogic(WithDispatch(WithDispatch(WithEffects))) (created by ComponentWithDispatch)
in ComponentWithDispatch (created by Context.Consumer)
in WithDispatch(WithConditionalLogic(WithDispatch(WithDispatch(WithEffects)))) (created by ComponentWithSelect)
in ComponentWithSelect (created by Context.Consumer)
in WithField(WithConditionalLogic(WithDispatch(WithDispatch(WithEffects)))) (created by WithFilters(WithFilters(TextField)))
in WithFilters(WithFilters(TextField)) (created by ComplexGroup)
in div (created by Field)
in div (created by Field)
in Field
in Unknown (created by WithFilters(Field))
in WithFilters(Field) (created by ComponentWithSelect)
in ComponentWithSelect (created by Context.Consumer)
in WithSelect(WithFilters(Field)) (created by WithFilters(WithSelect(WithFilters(Field))))
in WithFilters(WithSelect(WithFilters(Field))) (created by ComponentWithDispatch)
in ComponentWithDispatch (created by Context.Consumer)
in WithDispatch(WithFilters(WithSelect(WithFilters(Field)))) (created by ComponentWithSelect)
in ComponentWithSelect (created by Context.Consumer)
in WithField(WithFilters(WithSelect(WithFilters(Field)))) (created by ComplexGroup)
in div (created by ComplexGroup)
in div (created by ComplexGroup)
in ComplexGroup (created by ComplexField)
in div (created by ComplexField)
in Sortable (created by ComplexField)
in ComplexField (created by ComplexField)
in ComplexField
in Unknown (created by ComponentWithDispatch)
in ComponentWithDispatch (created by Context.Consumer)
in WithDispatch(Component) (created by ComponentWithSelect)
in ComponentWithSelect (created by Context.Consumer)
in WithSelect(WithDispatch(Component)) (created by WithFilters(ComplexField))
in WithFilters(ComplexField) (created by WithEffects)
in WithEffects (created by ComponentWithDispatch)
in ComponentWithDispatch (created by Context.Consumer)
in WithDispatch(WithEffects) (created by ComponentWithDispatch)
in ComponentWithDispatch (created by Context.Consumer)
in WithDispatch(WithDispatch(WithEffects)) (created by WithEffects)
in WithEffects (created by ComponentWithSelect)
in ComponentWithSelect (created by Context.Consumer)
in WithSelect(WithEffects) (created by ComponentWithDispatch)
in ComponentWithDispatch (created by Context.Consumer)
in WithConditionalLogic(WithDispatch(WithDispatch(WithEffects))) (created by ComponentWithDispatch)
in ComponentWithDispatch (created by Context.Consumer)
in WithDispatch(WithConditionalLogic(WithDispatch(WithDispatch(WithEffects)))) (created by ComponentWithSelect)
in ComponentWithSelect (created by Context.Consumer)
in WithField(WithConditionalLogic(WithDispatch(WithDispatch(WithEffects)))) (created by WithFilters(WithFilters(ComplexField)))
in WithFilters(WithFilters(ComplexField)) (created by Container)
in div (created by Field)
in div (created by Field)
in Field
in Unknown (created by WithFilters(Field))
in WithFilters(Field) (created by ComponentWithSelect)
in ComponentWithSelect (created by Context.Consumer)
in WithSelect(WithFilters(Field)) (created by WithFilters(WithSelect(WithFilters(Field))))
in WithFilters(WithSelect(WithFilters(Field))) (created by ComponentWithDispatch)
in ComponentWithDispatch (created by Context.Consumer)
in WithDispatch(WithFilters(WithSelect(WithFilters(Field)))) (created by ComponentWithSelect)
in ComponentWithSelect (created by Context.Consumer)
in WithField(WithFilters(WithSelect(WithFilters(Field)))) (created by Container)
in div (created by Container)
in div (created by Container)
in Container (created by WithFilters(Container))
in WithFilters(Container) (created by ComponentWithSelect)
in ComponentWithSelect (created by Context.Consumer)
in WithContainer(WithFilters(Container))

Consider adding an error boundary to your tree to customize error handling behavior.
Visit https://fb.me/react-error-boundaries to learn more about error boundaries.
logCapturedError @ react-dom.js?ver=16.8.4:17206
logError @ react-dom.js?ver=16.8.4:17242
update.callback @ react-dom.js?ver=16.8.4:18154
callCallback @ react-dom.js?ver=16.8.4:16522
commitUpdateEffects @ react-dom.js?ver=16.8.4:16561
commitUpdateQueue @ react-dom.js?ver=16.8.4:16549
commitLifeCycles @ react-dom.js?ver=16.8.4:17472
commitAllLifeCycles @ react-dom.js?ver=16.8.4:18825
callCallback @ react-dom.js?ver=16.8.4:143
invokeGuardedCallbackDev @ react-dom.js?ver=16.8.4:193
invokeGuardedCallback @ react-dom.js?ver=16.8.4:250
commitRoot @ react-dom.js?ver=16.8.4:19037
(anonymous) @ react-dom.js?ver=16.8.4:20507
unstable_runWithPriority @ react.js?ver=16.8.4:735
completeRoot @ react-dom.js?ver=16.8.4:20506
performWorkOnRoot @ react-dom.js?ver=16.8.4:20435
performWork @ react-dom.js?ver=16.8.4:20343
performSyncWork @ react-dom.js?ver=16.8.4:20317
interactiveUpdates$1 @ react-dom.js?ver=16.8.4:20584
interactiveUpdates @ react-dom.js?ver=16.8.4:2168
dispatchInteractiveEvent @ react-dom.js?ver=16.8.4:4985
react-dom.js?ver=16.8.4:20401 Uncaught TypeError: Cannot read property 'fields' of undefined
at getFieldsFromFieldsHolder (index.js:41)
at output (index.js:129)
at eval (index.js:66)
at Object.eval [as next] (index.es.js:219)
at eval (readme.js:53)
at eval (VM64436 callbag-distinct-until-changed.es.js:34)
at eval (VM64093 readme.js:48)
at eval (from-selector.js:28)
at data.js?ver=4.4.0:1362
at Array.forEach ()
getFieldsFromFieldsHolder @ index.js:41
output @ index.js:129
(anonymous) @ index.js:66
(anonymous) @ index.es.js:219
(anonymous) @ readme.js:53
(anonymous) @ callbag-distinct-until-changed.es.js:34
(anonymous) @ VM64093 readme.js:48
(anonymous) @ from-selector.js:28
(anonymous) @ data.js?ver=4.4.0:1362
globalListener @ data.js?ver=4.4.0:1361
(anonymous) @ data.js?ver=4.4.0:685
dispatch @ data.js?ver=4.4.0:3467
(anonymous) @ data.js?ver=4.4.0:558
(anonymous) @ data.js?ver=4.4.0:613
(anonymous) @ data.js?ver=4.4.0:778
proxyDispatch @ data.js?ver=4.4.0:2168
(anonymous) @ index.js:125
(anonymous) @ index.es.js:219
(anonymous) @ readme.js:53
(anonymous) @ VM64093 readme.js:48
(anonymous) @ VM64079 readme.js:27
(anonymous) @ VM64079 readme.js:27
(anonymous) @ VM64081 readme.js:31
next @ readme.js:58
(anonymous) @ index.es.js:233
(anonymous) @ index.es.js:232
instance.triggerUnmount @ index.es.js:293
WithEffects.componentWillUnmount @ index.es.js:358
callComponentWillUnmountWithTimer @ react-dom.js?ver=16.8.4:17258
callCallback @ react-dom.js?ver=16.8.4:143
invokeGuardedCallbackDev @ react-dom.js?ver=16.8.4:193
invokeGuardedCallback @ react-dom.js?ver=16.8.4:250
safelyCallComponentWillUnmount @ react-dom.js?ver=16.8.4:17265
commitUnmount @ react-dom.js?ver=16.8.4:17642
commitNestedUnmounts @ react-dom.js?ver=16.8.4:17673
unmountHostComponents @ react-dom.js?ver=16.8.4:17934
commitDeletion @ react-dom.js?ver=16.8.4:17993
commitAllHostEffects @ react-dom.js?ver=16.8.4:18774
callCallback @ react-dom.js?ver=16.8.4:143
invokeGuardedCallbackDev @ react-dom.js?ver=16.8.4:193
invokeGuardedCallback @ react-dom.js?ver=16.8.4:250
commitRoot @ react-dom.js?ver=16.8.4:19002
(anonymous) @ react-dom.js?ver=16.8.4:20507
unstable_runWithPriority @ react.js?ver=16.8.4:735
completeRoot @ react-dom.js?ver=16.8.4:20506
performWorkOnRoot @ react-dom.js?ver=16.8.4:20435
performWork @ react-dom.js?ver=16.8.4:20343
performSyncWork @ react-dom.js?ver=16.8.4:20317
interactiveUpdates$1 @ react-dom.js?ver=16.8.4:20584
interactiveUpdates @ react-dom.js?ver=16.8.4:2168
dispatchInteractiveEvent @ react-dom.js?ver=16.8.4:4985
Show 21 more frames

Conditional logic based on checkbox

When attempting to use conditional logic based on a checkbox, showing a sibling field when the checkbox is checked works as expected. However, only showing a field when the checkbox is unchecked does not:

Field::make_checkbox( 'curate_selection', _x( 'Curate the selection?', 'custom field label', 'xxx' ) )
	->set_option_value( true ),
Field::make_association( 'da_resource_types', __( 'DA Resource Types', 'scustom field label', 'xxx' ) )
	->set_conditional_logic( array(
		array(
			'field' => 'curate_selection',
			'value' => false,
		),
	) )
	->set_types( array(
		array(
			'type' => 'term',
			'taxonomy' => 'da_resource_type',
		),
	) ),
Field::make_association( 'da_resources', __( 'DA Resources', 'custom field label', 'xxx' ) )
	->set_max( 3 )
	->set_conditional_logic( array(
		array(
			'field' => 'curate_selection',
			'value' => true,
		),
	) )
	->set_types( array(
	     array(
		     'type'      => 'post',
		     'post_type' => 'da_resource',
	     ),
	) )

show_on_page() doesn't work without show_on_post_type('page') first

I am trying to register a container for a page with path "menukort" like this:

Container::make('post_meta', 'Allergener og kalorieindhold')
    ->show_on_page('menukort')
    ->add_fields(array(
        // pass
    ));

And unless I add show_on_post_type('page') before show_on_page, the container does not appear on the page.

I expect the container to automatically figure out that it needs to be displayed on a page post type, if I tell it to show_on_page.

Custom rules functions

Today, it is possible to add rules on top of the form's field values. I would like to know if it is possible to add functions to the rules.

Ex:

'rules' ['boolean'=> my_custom_function()]

'selected' property option

Hello! for the Select custom fields, is there support for the 'selected' property so I can preselect an option for the user? Thanks.

Can't attach submenu to a top level menu

I've created a top level menu for my specific need.
After that I would like to create a submenu and attach it to the top level menu by Carbon Fields and creating the options for the page.
But it noting working.

see the below code:

	function add_menu() {
		add_menu_page(
			esc_html__('Configuration', 'test'),
			esc_html__('TEST', 'test'),
			'manage_options',
			'test-configure',
			'configure_page',
			'dashicons-admin-generic',
			'50'
		);
	}
	add_action( 'admin_menu', 'add_menu' );

	Container::make( 'theme_options', esc_html__( 'Settings', 'test' ) )
		->set_page_menu_title( 'Settings' )
		->set_page_parent( 'test-configure' )
		->set_page_file( 'admin.php?page=test-settings' )
		->add_fields( [
			Field::make ...
		] );

Serialized datastore options saved in wp_options (network container)

Version

  • Carbon Fields: 2.2.0 (plugin)
  • WordPress: 4.9.4
  • PHP: 7.0.3

Expected Behavior

When using the Serialized Datastore example in a network container, values do not save to wp_sitemeta.

Actual Behavior

Instead, they appear to save to wp_options.

Container definition

Container::make( 'network', 'crb_my_network_container', 'CF Test' )
  ->set_page_parent( 'settings.php' )
  ->add_fields( array(
	Field::make( 'set', 'crb_set_field_example', 'My Set Field' )
	  ->set_datastore( new Serialized_Theme_Options_Datastore() )
	  ->add_options( $options )
  )
);

Comments

While this doesn't have an impact on functionality (carbon_get_network_option() still works), it seems inconsistent since other network container field values are stored in wp_sitemeta.

How can i create a field for the post, that have a few categories?

I use the version 3.0.
I write
->where( 'post_term', '=', array( 'field' => 'slug', 'value' => 'ambulance', 'taxonomy' => 'category', ) )
and i get a error.
After i clear, and write
->show_on_category('ambulance')
and it works, but why?

That this setting is for version 1.6.

And my main question.
How to create a field for the post, that have multiple categories?
Thanks.

And please, give me the link to the docs, where you find solution.
Thanks again.

Documentation showing reuse

All documentation examples show single-use case. Would be nice to see a page dedicated to showing how fields/complex fields can be reused. I feel like that's where the real power of this library is. Showing how to do it via functional programming like below as well as a class declaration I'm sure would be helpful to some:

    function getLinkGroup($name = 'link') {
        return Field::make( 'complex', $name )
            ->add_fields( array(
                Field::make( 'text', 'linktext'),
                Field::make( 'text', 'url'),
                Field::make( 'checkbox', 'newtab' ) )
            )
        );
    }

    function getImageGroup( $name = 'image' ) {
        return Field::make( 'complex', 'image' )
            ->add_fields( array(
                Field::make( 'image', 'mobile' ),
                Field::make( 'image', 'tablet' ),
                Field::make( 'image', 'desktop' ) )
            )
    }

    function getWysiwyg( $name = 'content' ) {
        return Field::make( 'rich_text', $name )
    }
    
    Container::make( 'post_meta', 'Author Info' )
        ->where( 'post_type', '=', 'post' )
        ->add_fields( array(
            getLinkGroup(),
            getImageGroup( 'avatar' ),
            getWysiwyg() )
        );
    
    Container::make( 'post_meta', 'Call To Action Button' )
        ->where( 'post_type', '=', 'page' )
        ->add_fields( array(
            getLinkGroup() )
        );

Composer.json custom location

I have composer.json one level up from web root and did not get it working following current instructions.
https://docs.carbonfields.net/#/plugin-quickstart

specifically

"extra": {
    "installer-paths": {
        "YOUR_DESIRED_LOCATION/vendor/{$vendor}/{$name}/": ["type:wordpress-plugin"]
    }
}

It was not sufficient.

To get it working I did some tweaks:

1. I had to define base url

define('Carbon_Fields\URL', home_url('/vendor/htmlburger/carbon-fields-plugin'));

Add this to "Plugin Quickstart" please.

2. I had to manually copy build folder from

vendor/htmlburger/carbon-fields/

to

web/vendor/htmlburger/carbon-fields-plugin/

Something missing in composer install step I suppose.

Header Permalinks in /docs

Is there a reasonable way to create GitHub-style anchor link clicks for the documentation headers?

I often reference it when both answering and asking questions, and it would be great to link to a section.

I don't mind inspecting the element to get the hashtag. If this is doable, I volunteer to do some PRs.

Anchors

Widgets fields not saving

When press save it must be saved . But it not happens. So when i try close window, browser warning me. But fields are saving to instance.

use Carbon_Fields\Field;
use Carbon_Fields\Widget;

class NeonTabWidget extends Widget {
    function __construct() {
        $this->setup( 'neon_tab_widget', esc_html__( '# Neon Tab Widget', 'neon' ), esc_html__( 'Display awesome neon tabs in anywhere!', 'neon' ), array(
            Field::make( 'text', 'title', esc_html_x( 'Title', 'Neon tab widget', 'neon' ) ),
            Field::make( 'set', 'fields', esc_html_x( 'Choose fields', 'Neon tab widget', 'neon' ) )
                ->set_options( array(
                    'w_titles'   => esc_html_x( 'Show titles', 'Neon tab widget', 'neon' ),
                    'tooltip'  => esc_html_x( 'Show tooltip', 'Neon tab widget', 'neon' ),
                ) ),
            Field::make( 'text', 'tab_fields', esc_html_x( 'Tab fields', 'Neon tab widget', 'neon' ) )
                ->set_default_value( 'p,l,c,t' )
                ->set_help_text( esc_html_x( 'p => Popular posts | l => Latest posts | c => Latest comments | t => Tags cloud', 'Neon tab widget', 'neon' ) ),
            Field::make( 'text', 'popular_count', esc_html_x( 'Popular count', 'Neon tab widget', 'neon' ) )
                ->set_attribute( 'type', 'number' )
                ->set_default_value( 5 )
                ->set_width( 33 ),
            Field::make( 'text', 'latest_count', esc_html_x( 'Latest post count', 'Neon tab widget', 'neon' ) )
                ->set_attribute( 'type', 'number' )
                ->set_default_value( 5 )
                ->set_width( 33 ),
            Field::make( 'text', 'comment_count', esc_html_x( 'Comment count', 'Neon tab widget', 'neon' ) )
                ->set_attribute( 'type', 'number' )
                ->set_default_value( 5 )
                ->set_width( 33 ),
        ) );
    }

    // Called when rendering the widget in the front-end
    function front_end( $args, $instance ) {
    }
}

register_widget( 'NeonTabWidget' );

Complex Filed layout tabbed backwards compatibility

Many of the themes that I have created use complex fields, and have the layout set to 'tabbed'. With the latest update to Carbon Fields, the layout needs to be 'tabbed-horizontal' now, but everything that I wrote to use 'tabbed' no longer shows it as tabs but is reset back to default.

updating problem

1-when update from 1.3 to 1.5 i lose all the saved values in entry

complex fields issue on carbon fields upgrade from 1.6 to 3.1

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 ?

Association search not functioning as expected for large # of entries with body text

Context

We have successfully used the association field to embed content type taxonomies (videos, photo galleries) of which there are a few thousand entries - search results are quite snappy and provide pleasant UX.

However, using the association field to embed articles inside other articles (of which there are 30-60k+ per site), the search feature returns undesirable results 9 times out of 10. My guess is that the search field is perhaps trying to compare keywords to the body content of every article in the 30k+ entries, rather than just the titles? I could be wrong in that assumption.

The search lags very intensely for articles, where the bulk of the time it returns segmented iterations of results, none of which have any relation to the query.

Undesired current article block search

Screen Recording 2020-12-18 at 3 36 08 PM

Working example with Video Block

Although videos often have body text as well (much less than articles) the search works just fine
Screen Recording 2020-12-18 at 3 46 46 PM

However, while still quite slow for the articles...

This specific query was found to return some expected results

image

As does the video block

image

Desired outcome

I'm looking for a way to have the search feature strictly compare to the post taxonomy (our articles) title content, and return relevant results. Could I perhaps specify something in the association query to compare the search query to ONLY the post title?

Currently...

        Field::make('association', 'gnl_article_embed', __('Article'))
            ->set_types(array(
                array(
                    'type'          => 'post',
                    'post_type'     => 'post',
                ),
            ))

Respective code

Video Block

Block::make(__('Video Embed'))
  ->add_fields(array(
    Field::make('html', 'video_information_text')
      ->set_html('<h2>Video Embed</h2><p><span style="color: red">Please note:</span> The video has to be published to the sites that this article is published to for the video to show up in the article</p>'),
    Field::make('association', 'gnl_video_embed', __('Video'))
      ->set_types(array(
        array(
          'type'      => 'post',
          'post_type' => 'gnl_videos',
        )
      ))
      ->set_min(1)
      ->set_max(1)

  ))
  ->set_category('gnl_blocks', __('Blocks by <Company Name>'), '')
  ->set_icon('video-alt2')
  ->set_preview_mode(true)
  ->set_render_callback(function ($video_block) { ... });
...

Article Block

Block::make(__('Article Embed'))
    ->add_fields(array(
        Field::make('html', 'article_information_text')
            ->set_html('<h2>Article Embed</h2><p><span style="color: red">Please note:</span> The embedded article has to be published to the sites that this post is published to for the embedded article to show up in this post</p>'),
        Field::make('association', 'gnl_article_embed', __('Article'))
            ->set_types(array(
                array(
                    'type'          => 'post',
                    'post_type'     => 'post',
                ),
            ))
            ->set_min(1)
            ->set_max(1)

    ))
    ->set_category('gnl_blocks', __('Blocks by <Company Name>'), '')
    ->set_icon('media-document')
    ->set_preview_mode(true)
    ->set_render_callback(function ($article_block) { ... });
...

Gutenberg block name translation

If you change translation of the block name, the block is no longer available. It should be preferable to use a machine name and a displayed name. This is not really an issue I think but maybe a documentation problem

Block::make( __( 'Block Flexible', 'domain_name' ) )

The code in the editor is the following :

Network Container example

Version

  • Carbon Fields: 2.2.0
  • WordPress: 4.9.4
  • PHP: 7.0.3

Comments

Currently, the page for the new network container suggests that you reference the theme_options docs.

I'm thinking that it may be useful to add some quick examples, particularly since carbon_get_network_option() requires a site site ID to be passed.

Further, since the function does not accept null for the network site ID (as get_network_option() does), it may be helpful to include in the example passing the current SITE_ID_CURRENT_SITE (if defined).

EDIT: In looking at the code to verify this post, I discovered the carbon_get_the_network_option() function, which I was not aware of until now. It may be useful to mention that function on the page as well, since I would imagine (??) that, quite often, you're probably looking to get a network option for the current site ID. YMMV

Semi-related note: carbon_get_network_option() should probably allow null for the site ID (and thus default to SITE_ID_CURRENT_SITE) to be consistent with WordPress's get_network_option().

EDIT 2: I am swamped with my current project, but when/if I ever have time, I would be willing to submit a PR for the docs. It may be awhile, though, so if anyone here has time, I would be open to assisting.

How to display options justo on posts, that have a common category?

I write this code
Container::make( 'post_meta', __( 'Icons' ) ) ->show_on_category('leadership') ->add_fields([ Field::make( 'text', 'crb_leadership_icon_class_first', __( 'Icon class' ) ) ->set_required(), Field::make( 'text', 'crb_leadership_icon_class_second', __( 'Icon class' ) ) ->set_required(), ]);

But phpstorm show for me, that method "show_on_category" doesn't exist.

Or this method is for the oldes versions?

how to use as a library

i was wondering if instead of plugin i can use the carbon-fields as library that i include in my theme without installing it at all is there a way to do that thanks

Real time carbon field changes

Hi,

I have experience using CF 2, but I've been learning to use 3 so I can use it with Gutenberg. One of the features I have is to be able to change one carbon field dropdown, to populate the value of another field.

I know that I can use PHP and just update the value on the save_post hook, but you have to save/update the post for the function to run. Is there a way to use JS to do this so we can see the field populating in real time?

Reason I ask is because I'm trying to figure it out, and it doesn't seem like CF 3 was meant to be handled this way. The IDs of the fields literally generate and change on page refresh, so the DOM couldn't find the field by ID. I used the name attribute instead. And now trying to get the selected value on the dropdown isn't working either. It doesn't seem like the CF dropdown actually applies the selected attribute to whatever option you choose. It's definitely making the whole JS thing a challenge... so maybe there's just a better way to do it?

I saw something about WordPress JS hooks in the documentation, but I'm trying to avoid installing a new package if I can. It just sounds like overkill for this minor feature. Can this be done on the JS side without resorting to WordPress' JS Hooks?

Thanks.

Uncaught Error: Class 'Carbon_Fields\Block'

Hello,
I've just installed Carbon Fields with composer.
I've tried the quickstart example and it works great but when I try the Gutenberg Block example

use Carbon_Fields\Block;

Block::make( __( 'My Shiny Gutenberg Block' ) )
    ->add_fields( array(
        Field::make( 'text', 'heading', __( 'Block Heading' ) ),
        Field::make( 'image', 'image', __( 'Block Image' ) ),
        Field::make( 'rich_text', 'content', __( 'Block Content' ) ),
    ) )
    ->set_category( 'Perrine Voinson', __( 'Perrine Voinson' ), 'dashicons-admin-multisite' )
    ->set_render_callback( function ( $fields, $attributes, $inner_blocks ) {
        ?>

        <div class="block">
            <div class="block__heading">
                <h1><?php echo esc_html( $fields['heading'] ); ?></h1>
            </div><!-- /.block__heading -->

            <div class="block__image">
                <?php echo wp_get_attachment_image( $fields['image'], 'full' ); ?>
            </div><!-- /.block__image -->

            <div class="block__content">
                <?php echo apply_filters( 'the_content', $fields['content'] ); ?>
            </div><!-- /.block__content -->
        </div><!-- /.block -->

        <?php
    } );

Here is what I got:

Fatal error: Uncaught Error: Class 'Carbon_Fields\Block' not found in E:\DEV*\Site\wp-content\themes*\includes\carbonfields.php on line 5

Could you help me on this weird php error ?

Many thanks, your work looks awesome btw.

Arnaud

Field type file look and feel issue

Before press 'Save Changes' or after press 'Use File' it shows like this

image

After click 'Save Changes'

image

It makes user feel that the upload file not there or not being used.

How to make the field shows like 'Before' and 'After' press 'Save Changes'?

How can i localize the date picker

Cannot set datepicker language. Flatpickr includes localized option vía "locale", but I cannot use it since the localization scripts are not loaded and the following console error is displayed: "Error: flatpickr: invalid locale es"

Could you add support to set the location of the datepicker based on the Wordpress current language?

tabs

I am using v1.3 and have complex field in tabs
the problem is the tab take too much time to load and sometimes user update the page before the tabs fully loaded and that cause losing all the values in the fields
anyway i can prevent that????

Gutenberg block value to meta field

Is there a way to let gutenberg blocks created with Carbon fields store (or copy) the value to post meta as well? Like in this native method .

If not supported, anyone a suggestion as to how to work around this? A clever hack?

wc_get_products() returns empty array

I wanted to create a dropdown with WooCommerce products, using the standard wc_get_products([]) function returns an empty array though. That's probably because the carbon_fields_register_fields hook is called too early.

Any fix for this?

Thanks!

Images sub-fields in a complex field are not displayed, but value is saved

I have a complex field with an image sub-field in it, registered as such:

Field::make( 'complex', 'profile_tags', __( 'Titre', 'freebulle' ) )
	->add_fields( [
		Field::make( 'checkbox', 'is_active', __( 'Actif ?', 'freebulle' ) )
			->set_option_value( 'yes' )
			->set_width( 12 ),
		Field::make( 'select', 'group', __( 'Groupe', 'freebulle' ) )
			->set_required( true )
			->set_options( Config::get_profile_tags_groups() )
			->set_width( 22 ),
		Field::make( 'text', 'slug', __( 'Identifiant unique', 'freebulle' ) )
			->set_required( true )
			->set_width( 22 ),
		Field::make( 'text', 'name', __( 'Nom', 'freebulle' ) )
			->set_required( true )
			->set_width( 22 ),
		Field::make( 'image', 'icon', __( 'Icône', 'freebulle' ) )
			->set_required( true )
			->set_type( [ 'image' ] )
			->set_width( 22 ),
	] )
	->setup_labels( [
		'singular_name' => __( 'Tag', 'freebulle' ),
		'plural_name'   => __( 'Tags', 'freebulle' ),
	] )
	->set_header_template( 'Tag n°<%- $_index+1 %>' )

For the icon field, the image IDs are correctly saved in the database. But when the page is refreshed, the field appears empty.

You can see an example here: on the left side, _profile_tags|icon|%|%|value options do have a value, but the fields appear empty on the right side:
Screen 2021-03-10 à 06 46 30

Can't get Complex field value

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!

Add CONTRIBUTING.md

I think that this repo could use a CONTRIBUTING.md. Looking at the CF issues forum, it seems as though more and more people are interested in expanding the docs and/or proposing changes.

After plugin activate error 500

Hello!
I've used manual "Plugin Quickstart", installing via composer. And after activate it in admin panel, I get 500 error.
In some reason plugin tryes to open file _ _ DIR _ _ . '/vendor/autoload.php' (23 line of file /wp-content/plugins/carbon-fields-plugin/carbon-fields-plugin.php).
But directory "vendor" vas created in root dir of site.
So, replacing "_ _ DIR _ _" to "$_SERVER['DOCUMENT_ROOT']" solvig the problem, but it's not good decision.

Conditional logic in Gutenberg block

Hi I 'm workin on a Gutenberg block and the conditional logic doesn’t works.

Error in console: An unknown field is used in condition - “crb_show_socials”

in my functions :

Field::make( 'select', 'crb_show_socials', 'Show Socials' )
->add_options( array(
'yes' => 'Yes',
'no' => 'No',
) ),
Field::make( 'text', 'crb_facebook', 'Facebook URL' )
->set_conditional_logic( array(
'relation' => 'AND', // Optional, defaults to "AND"
array(
'field' => 'crb_show_socials',
'value' => array('yes'),
'compare' => 'IN',
)
) ),

Any ideas? is it a bug?

Converting legacy keys to new format

How can I convert a legacy key to the new 2.0 compatible format?

I would be nice to have a single function, which takes old key as a parameter and returns a new key.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.