AdvancedCustomFields / AdvancedCustomFields/acf

ACF 5.8-Beta-4.1: Some radio buttons values are not going to be retrieved in the editor and front-end

Open
#164 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PHP
Stars
945
Forks
197
PR merge metrics
No merged PRs in 30d

Description

A very strange bug bugged me today.
I have a simple radio buttons field with values like:

  • page
  • icon
  • link
  • file

It occurs that the two last choices cannot be retrieved in ACF Beta 4.1. When I select one of them, save the page and reload, default choice (page) is selected. Also, there are errors in the console when loading.
When I switch to the code editor, the choice is saved as "mytest-section-type":"file"
It seems that words like link or file are somehow restricted when they are going to be displayed. Maybe there are more of such words (I checked 'text', 'url', 'email', but these are OK)?

/**
 * Test ACF blocks in 5.8-beta4
 */

add_action( 'acf/init', 'my_acf_blocks_init' );
function my_acf_blocks_init() {
	/**
	 * Register block
	 */
	acf_register_block_type( array(
		'name'            => 'mytest',
		'title'           => __( 'My Test Block', 'my-acf' ),
		'description'     => __( 'A block for testing ACF Beta.', 'my-acf' ),
		'render_callback' => 'my_acf_block_render_callback',
		'category'        => 'formatting',
		'icon'            => 'external',
		'keywords'        => array(),
		'supports'        => array( 'align' => false ),
		'mode'            => 'edit',
	) );

	/**
	 * Define block fields
	 */
	acf_add_local_field_group( array(
		'key' => "group_mytest",
		'title' => __( 'Block :: My Test Block', 'my-acf' ),
		'location' => array(
			array(
				array(
					'param' => 'block',
					'operator' => '==',
					'value' => 'acf/mytest',
				),
			),
		),
		'fields' => array(
			array(
				'key' => "field_mytest-section-type",
				'label' => __( 'Section type', 'my-acf' ),
				'name' => "mytest-section-type",
				'type' => 'radio',
				'choices' => array(
					'page' => __( 'Page', 'my-acf'),
					'icon' => __( 'Icon', 'my-acf'),
					'link' => __( 'Link', 'my-acf'),
					'file' => __( 'File', 'my-acf'),
				),
				'default_value' => 'page',
				'layout' => 'horizontal',
			),
		),
	) );
}

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Use the supplied ACF block registration and radio-field example as the reproduction case. Start by tracing how the radio choices are rendered and restored in the block editor, then check the console errors when reloading; done means the link and file choices persist and are retrieved in both the editor and front end.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend, frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.