Support

Account

Home Forums Add-ons Flexible Content Field Conditional rules error

Solving

Conditional rules error

  • Suddenly after updating acf to the v4.3.1 the following error has started popping up:

    Warning: array_values() expects parameter 1 to be array, string given in /home/ringvhfx/public_html/wp-content/plugins/advanced-custom-fields/core/fields/_functions.php on line 431

    The error appears during printing of a flexible content field.

    I checked the source, and found that it must be related to conditional rules. I don’t use any conditional rules in my flexible content field (or any other place on my site, really).

    What might be causing this?

  • Hi @stiaje

    I’m not sure how your conditional logic could be a string, can you please export your field group to PHP and copy / paste the flexible content field in question so I can see what the conditional logic value is?

    If the export doesn’t work due to this error, perhaps look in the db wp_postmeta table where the post_id = field group ID, the meta_key = field_key and then copy out the meta_value

    Thanks
    E

  • The php export is:

    if(function_exists("register_field_group"))
    {
    	register_field_group(array (
    		'id' => 'acf_long-page',
    		'title' => 'Long page',
    		'fields' => array (
    			array (
    				'key' => 'field_5',
    				'label' => 'Layout',
    				'name' => 'long_page_layout',
    				'type' => 'flexible_content',
    				'layouts' => array (
    					array (
    						'label' => 'Fritekst',
    						'name' => 'fritekst',
    						'display' => 'row',
    						'min' => '',
    						'max' => '',
    						'sub_fields' => array (
    							array (
    								'key' => 'field_51d51ce1bf114',
    								'label' => 'Title',
    								'name' => 'title',
    								'type' => 'title',
    								'column_width' => '',
    							),
    							array (
    								'key' => 'field_6',
    								'label' => 'Content',
    								'name' => 'content',
    								'type' => 'wysiwyg',
    								'column_width' => '',
    								'default_value' => '',
    								'toolbar' => 'full',
    								'media_upload' => 'yes',
    							),
    							array (
    								'key' => 'field_51d51cecbf115',
    								'label' => 'Include in menu',
    								'name' => 'include_in_menu',
    								'type' => 'true_false',
    								'instructions' => 'Gjelder for engelsk og tysk',
    								'column_width' => '',
    								'message' => 'Vis i toppmeny',
    								'default_value' => 0,
    							),
    							array (
    								'key' => 'field_51d5460254d84',
    								'label' => 'Menu title',
    								'name' => 'menu_title',
    								'type' => 'text',
    								'instructions' => 'Vil vises i toppmenyen',
    								'column_width' => '',
    								'default_value' => '',
    								'placeholder' => '',
    								'prepend' => '',
    								'append' => '',
    								'formatting' => 'none',
    								'maxlength' => '',
    							),
    						),
    					),
    					array (
    						'label' => 'Slider',
    						'name' => 'slider',
    						'display' => 'row',
    						'min' => '',
    						'max' => '',
    						'sub_fields' => array (
    							array (
    								'key' => 'field_7',
    								'label' => 'Royalslider id',
    								'name' => 'royalslider_id',
    								'type' => 'number',
    								'column_width' => '',
    								'default_value' => '',
    								'placeholder' => '',
    								'prepend' => '',
    								'append' => '',
    								'min' => '',
    								'max' => '',
    								'step' => '',
    							),
    						),
    					),
    					array (
    						'label' => 'Highlights-linje',
    						'name' => 'highlight_strip',
    						'display' => 'row',
    						'min' => '',
    						'max' => '',
    						'sub_fields' => array (
    							array (
    								'key' => 'field_8',
    								'label' => 'Content Blocks',
    								'name' => 'content_blocks',
    								'type' => 'relationship',
    								'column_width' => '',
    								'return_format' => 'object',
    								'post_type' => array (
    									0 => 'content_block',
    								),
    								'taxonomy' => array (
    									0 => 'all',
    								),
    								'filters' => array (
    									0 => 'search',
    								),
    								'result_elements' => array (
    									0 => 'post_type',
    									1 => 'post_title',
    								),
    								'max' => 3,
    							),
    						),
    					),
    					array (
    						'label' => 'Bilde og tekst',
    						'name' => 'bilde_og_tekst',
    						'display' => 'row',
    						'min' => '',
    						'max' => '',
    						'sub_fields' => array (
    							array (
    								'key' => 'field_39',
    								'label' => 'Title',
    								'name' => 'title',
    								'type' => 'title',
    								'instructions' => 'overskriften',
    								'column_width' => '',
    							),
    							array (
    								'key' => 'field_10',
    								'label' => 'Content',
    								'name' => 'content',
    								'type' => 'wysiwyg',
    								'column_width' => '',
    								'default_value' => '',
    								'toolbar' => 'full',
    								'media_upload' => 'no',
    							),
    							array (
    								'key' => 'field_11',
    								'label' => 'Image',
    								'name' => 'image',
    								'type' => 'image',
    								'column_width' => '',
    								'save_format' => 'id',
    								'preview_size' => 'event-thumb',
    								'library' => 'all',
    							),
    							array (
    								'key' => 'field_51d51c87bf112',
    								'label' => 'Include in menu',
    								'name' => 'include_in_menu',
    								'type' => 'true_false',
    								'instructions' => 'Gjelder for engelsk og tysk side',
    								'column_width' => '',
    								'message' => 'Vis i toppmeny',
    								'default_value' => 0,
    							),
    							array (
    								'key' => 'field_51d5463154d85',
    								'label' => 'Menu title',
    								'name' => 'menu_title',
    								'type' => 'text',
    								'instructions' => 'Vil vises i toppmenyen',
    								'column_width' => '',
    								'default_value' => '',
    								'placeholder' => '',
    								'prepend' => '',
    								'append' => '',
    								'formatting' => 'none',
    								'maxlength' => '',
    							),
    						),
    					),
    					array (
    						'label' => 'Galleri/bildemeny',
    						'name' => 'galleri',
    						'display' => 'row',
    						'min' => '',
    						'max' => '',
    						'sub_fields' => array (
    							array (
    								'key' => 'field_14',
    								'label' => 'Bilde 1',
    								'name' => 'bilde_1',
    								'type' => 'image',
    								'column_width' => '',
    								'save_format' => 'id',
    								'preview_size' => 'event-thumb',
    								'library' => 'all',
    							),
    							array (
    								'key' => 'field_18',
    								'label' => 'Tittel 1',
    								'name' => 'tittel_1',
    								'type' => 'text',
    								'column_width' => '',
    								'default_value' => '',
    								'placeholder' => '',
    								'prepend' => '',
    								'append' => '',
    								'formatting' => 'html',
    								'maxlength' => '',
    							),
    							array (
    								'key' => 'field_19',
    								'label' => 'Link 1',
    								'name' => 'link_1',
    								'type' => 'page_link',
    								'column_width' => '',
    								'post_type' => array (
    									0 => 'page',
    								),
    								'allow_null' => 0,
    								'multiple' => 0,
    							),
    							array (
    								'key' => 'field_15',
    								'label' => 'Bilde 2',
    								'name' => 'bilde_2',
    								'type' => 'image',
    								'column_width' => '',
    								'save_format' => 'id',
    								'preview_size' => 'event-thumb',
    								'library' => 'all',
    							),
    							array (
    								'key' => 'field_23',
    								'label' => 'Tittel 2',
    								'name' => 'tittel_2',
    								'type' => 'text',
    								'column_width' => '',
    								'default_value' => '',
    								'placeholder' => '',
    								'prepend' => '',
    								'append' => '',
    								'formatting' => 'html',
    								'maxlength' => '',
    							),
    							array (
    								'key' => 'field_20',
    								'label' => 'Link 2',
    								'name' => 'link_2',
    								'type' => 'page_link',
    								'column_width' => '',
    								'post_type' => array (
    									0 => 'all',
    								),
    								'allow_null' => 1,
    								'multiple' => 0,
    							),
    							array (
    								'key' => 'field_16',
    								'label' => 'Bilde 3',
    								'name' => 'bilde_3',
    								'type' => 'image',
    								'column_width' => '',
    								'save_format' => 'id',
    								'preview_size' => 'event-thumb',
    								'library' => 'all',
    							),
    							array (
    								'key' => 'field_22',
    								'label' => 'Tittel 3',
    								'name' => 'tittel_3',
    								'type' => 'text',
    								'column_width' => '',
    								'default_value' => '',
    								'placeholder' => '',
    								'prepend' => '',
    								'append' => '',
    								'formatting' => 'html',
    								'maxlength' => '',
    							),
    							array (
    								'key' => 'field_25',
    								'label' => 'Link 3',
    								'name' => 'link_3',
    								'type' => 'page_link',
    								'column_width' => '',
    								'post_type' => array (
    									0 => 'page',
    								),
    								'allow_null' => 1,
    								'multiple' => 0,
    							),
    							array (
    								'key' => 'field_17',
    								'label' => 'Bilde 4',
    								'name' => 'bilde_4',
    								'type' => 'image',
    								'column_width' => '',
    								'save_format' => 'id',
    								'preview_size' => 'event-thumb',
    								'library' => 'all',
    							),
    							array (
    								'key' => 'field_21',
    								'label' => 'Tittel 4',
    								'name' => 'tittel_4',
    								'type' => 'text',
    								'column_width' => '',
    								'default_value' => '',
    								'placeholder' => '',
    								'prepend' => '',
    								'append' => '',
    								'formatting' => 'html',
    								'maxlength' => '',
    							),
    							array (
    								'key' => 'field_24',
    								'label' => 'Link 4',
    								'name' => 'link_4',
    								'type' => 'page_link',
    								'column_width' => '',
    								'post_type' => array (
    									0 => 'page',
    								),
    								'allow_null' => 1,
    								'multiple' => 0,
    							),
    						),
    					),
    				),
    				'button_label' => 'Add Row',
    				'min' => '',
    				'max' => '',
    			),
    		),
    		'location' => array (
    			array (
    				array (
    					'param' => 'page_template',
    					'operator' => '==',
    					'value' => 'page-long.php',
    					'order_no' => 0,
    					'group_no' => 0,
    				),
    			),
    		),
    		'options' => array (
    			'position' => 'normal',
    			'layout' => 'no_box',
    			'hide_on_screen' => array (
    				0 => 'excerpt',
    				1 => 'discussion',
    				2 => 'comments',
    				3 => 'author',
    				4 => 'format',
    				5 => 'categories',
    				6 => 'tags',
    			),
    		),
    		'menu_order' => 0,
    	));
    }

    I should also note, all content is printed. It just comes after the warning message.

  • Hi @stiaje

    Thanks for the field group code.
    None of the above fields contain any conditional_logic data, so i can’t understand why you are receiving an error complaining that a the value of ‘conditional_logic’ is a string.

    I also pasted your code into my functions.php file and the fields load correctly without any errors.

    I think the error must come from another field group.

Viewing 4 posts - 1 through 4 (of 4 total)

The topic ‘Conditional rules error’ is closed to new replies.